window
#
alias of |
|
|
Keyframe animation class. |
alias of |
|
Manipulate the camera and interact with objects in the scene. |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
|
Your scene class. |
|
Class interface between the scene, the window and the interactor. |
alias of |
|
|
Keyframe animation Timeline. |
alias of |
|
alias of |
|
alias of |
|
|
|
|
Analyze snapshot from memory or file. |
|
Enable anti-aliasing and ordered transparency. |
|
|
|
Enable the given stereo type on the RenderWindow. |
|
This it will disable any gl behavior which has no function for opaque objects. |
|
Disable OpenGl depth test |
|
Enable OpenGl blending |
|
Enable OpenGl depth test |
|
Returns a dict which describes the current state of the opengl context |
|
Redefines the state of the OpenGL context related with how the RGBA channels will be combined. |
|
Enable additive blending |
Enable additive blending for a white background |
|
|
Enable multiplicative blending |
|
Enable normal blending |
|
Enable subtractive blending |
|
Load an image. |
|
Record a video of your scene. |
|
Save a 2d or 3d image. |
|
Show window with current scene. |
|
Save a snapshot of the scene in a file or in memory. |
|
Issue a warning, or maybe ignore it or raise an exception. |
Actor2D
#
- fury.window.Actor2D#
alias of
vtkActor2D
Animation
#
- class fury.window.Animation(actors=None, length=None, loop=True, motion_path_res=None)[source]#
Bases:
object
Keyframe animation class.
Animation is responsible for keyframe animations for a single or a group of actors. It’s used to handle multiple attributes and properties of Fury actors such as transformations, color, and scale. It also accepts custom data and interpolates them, such as temperature. Linear interpolation is used by default to interpolate data between the main keyframes.
- length#
the fixed length of the animation. If set to None, the animation will get its duration from the keyframes being set.
- loop#
Whether to loop the animation (True) of play once (False).
- Type:
bool, optional, default: True
- motion_path_res#
the number of line segments used to visualizer the animation’s motion path (visualizing position).
- Type:
int, default: None
- property actors#
Return a list of actors.
- Returns:
List of actors controlled by the Animation.
- Return type:
- add(item)[source]#
Add an item to the Animation. This item can be an Actor, Animation, list of Actors, or a list of Animations.
- add_static_actor(actor)[source]#
Add an actor or list of actors as static actor/s which will not be controlled nor animated by the Animation. All static actors will be added to the scene when the Animation is added to the scene.
- Parameters:
actor (vtkActor or list(vtkActor)) – Static actor/s.
- add_to_scene_at(timestamp)[source]#
Set timestamp for adding Animation to scene event.
- Parameters:
timestamp (float) – Timestamp of the event.
- add_update_callback(callback, prop=None)[source]#
Add a function to be called each time animation is updated This function must accept only one argument which is the current value of the named property.
- Parameters:
callback (callable) – The function to be called whenever the animation is updated.
prop (str, optional, default: None) – The name of the property.
Notes
If no attribute name was provided, current time of the animation will be provided instead of current value for the callback.
- property child_animations: list[fury.animation.animation.Animation]#
Return a list of child Animations.
- Returns:
List of child Animations of this Animation.
- Return type:
- property current_timestamp#
Return the current time of the animation.
- Returns:
The current time of the animation.
- Return type:
- property duration#
Return the duration of the animation.
- Returns:
The duration of the animation.
- Return type:
- get_color(t)[source]#
Return the interpolated color.
- Parameters:
t (float) – The time to interpolate color value at.
- Returns:
The interpolated color.
- Return type:
ndarray(1, 3)
- get_current_value(attrib)[source]#
Return the value of an attribute at current time.
- Parameters:
attrib (str) – The attribute name.
- get_keyframes(attrib=None)[source]#
Get a keyframe for a specific or all attributes.
- Parameters:
attrib (str, optional, default: None) – The name of the attribute. If None, all keyframes for all set attributes will be returned.
- get_opacity(t)[source]#
Return the opacity value.
- Parameters:
t (float) – The time to interpolate opacity at.
- Returns:
The interpolated opacity.
- Return type:
ndarray(1, 1)
- get_position(t)[source]#
Return the interpolated position.
- Parameters:
t (float) – The time to interpolate position at.
- Returns:
The interpolated position.
- Return type:
ndarray(1, 3)
- get_scale(t)[source]#
Return the interpolated scale.
- Parameters:
t (float) – The time to interpolate scale at.
- Returns:
The interpolated scale.
- Return type:
ndarray(1, 3)
- is_inside_scene_at(timestamp)[source]#
Check if the Animation is set to be inside the scene at a specific timestamp.
- Returns:
True if the Animation is set to be inside the scene at the given timestamp.
- Return type:
Notes
If the parent Animation is set to be out of the scene at that time, all of their child animations will be out of the scene as well.
- is_interpolatable(attrib)[source]#
Check whether a property is interpolatable.
- Parameters:
attrib (str) – The name of the property.
- Returns:
True if the property is interpolatable by the Animation.
- Return type:
Notes
True means that it’s safe to use Interpolator.interpolate(t) for the specified property. And False means the opposite.
- property loop#
Get loop condition of the current animation.
- Returns:
Whether the animation in loop mode (True) or play one mode (False).
- Return type:
- property parent_animation#
Return the hierarchical parent Animation for current Animation.
- Returns:
The parent Animation.
- Return type:
- remove_actor(actor)[source]#
Remove an actor from the Animation.
- Parameters:
actor (vtkActor) – Actor to be removed from the Animation.
- remove_from_scene_at(timestamp)[source]#
Set timestamp for removing Animation to scene event.
- Parameters:
timestamp (float) – Timestamp of the event.
- set_color(timestamp, color, **kwargs)[source]#
Set color keyframe at a specific timestamp.
- Parameters:
timestamp (float) – Timestamp of the keyframe
color (ndarray, shape(1, 3)) – Color keyframe value associated with the timestamp.
- set_color_interpolator(interpolator, is_evaluator=False)[source]#
Set the color interpolator.
- Parameters:
interpolator (callable) – The generator function of the interpolator that would handle the color keyframes.
is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.
Examples
>>> Animation.set_color_interpolator(lab_color_interpolator)
- set_color_keyframes(keyframes)[source]#
Set a dict of color keyframes at once. Should be in the following form: {timestamp_1: color_1, timestamp_2: color_2}
- Parameters:
keyframes (dict) – A dict with timestamps as keys and color as values.
Examples
>>> color_keyframes = {1, np.array([1, 0, 1]), 3, np.array([0, 0, 1])} >>> Animation.set_color_keyframes(color_keyframes)
- set_interpolator(attrib, interpolator, is_evaluator=False, **kwargs)[source]#
Set keyframes interpolator for a certain property
- Parameters:
attrib (str) – The name of the property.
interpolator (callable) – The generator function of the interpolator to be used to interpolate/evaluate keyframes.
is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes such as: >>> def get_position(t): >>> return np.array([np.sin(t), np.cos(t) * 5, 5])
spline_degree (int, optional) – The degree of the spline in case of setting a spline interpolator.
Notes
If an evaluator is used to set the values of actor’s properties such as position, scale, color, rotation, or opacity, it has to return a value with the same shape as the evaluated property, i.e.: for scale, it has to return an array with shape 1x3, and for opacity, it has to return a 1x1, an int, or a float value.
Examples
>>> Animation.set_interpolator('position', linear_interpolator)
>>> pos_fun = lambda t: np.array([np.sin(t), np.cos(t), 0]) >>> Animation.set_interpolator('position', pos_fun)
- set_keyframe(attrib, timestamp, value, update_interpolator=True, **kwargs)[source]#
Set a keyframe for a certain attribute.
- Parameters:
attrib (str) – The name of the attribute.
timestamp (float) – Timestamp of the keyframe.
value (ndarray or float or bool) – Value of the keyframe at the given timestamp.
update_interpolator (bool, optional) – Interpolator will be reinitialized if Ture
in_cp (ndarray, shape (1, M), optional) – The in control point in case of using cubic Bézier interpolator.
out_cp (ndarray, shape (1, M), optional) – The out control point in case of using cubic Bézier interpolator.
in_tangent (ndarray, shape (1, M), optional) – The in tangent at that position for the cubic spline curve.
out_tangent (ndarray, shape (1, M), optional) – The out tangent at that position for the cubic spline curve.
- set_keyframes(attrib, keyframes)[source]#
Set multiple keyframes for a certain attribute.
- Parameters:
Notes
Keyframes can be on any of the following forms: >>> key_frames_simple = {1: [1, 2, 1], 2: [3, 4, 5]} >>> key_frames_bezier = {1: {‘value’: [1, 2, 1]}, >>> 2: {‘value’: [3, 4, 5], ‘in_cp’: [1, 2, 3]}} >>> pos_keyframes = {1: np.array([1, 2, 3]), 3: np.array([5, 5, 5])} >>> Animation.set_keyframes(‘position’, pos_keyframes)
- set_opacity(timestamp, opacity, **kwargs)[source]#
Set opacity keyframe at a specific timestamp.
- Parameters:
timestamp (float) – Timestamp of the keyframe
opacity (ndarray, shape(1, 3)) – Opacity keyframe value associated with the timestamp.
- set_opacity_interpolator(interpolator, is_evaluator=False)[source]#
Set the opacity interpolator.
- Parameters:
interpolator (callable) – The generator function of the interpolator that would handle the opacity keyframes.
is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.
Examples
>>> Animation.set_opacity_interpolator(step_interpolator)
- set_opacity_keyframes(keyframes)[source]#
Set a dict of opacity keyframes at once. Should be in the following form: {timestamp_1: opacity_1, timestamp_2: opacity_2}
- Parameters:
keyframes (dict(float: ndarray, shape(1, 1) or float or int)) – A dict with timestamps as keys and opacities as values.
Notes
Opacity values should be between 0 and 1.
Examples
>>> opacity = {1, np.array([1, 1, 1]), 3, np.array([2, 2, 3])} >>> Animation.set_scale_keyframes(opacity)
- set_position(timestamp, position, **kwargs)[source]#
Set a position keyframe at a specific timestamp.
- Parameters:
timestamp (float) – Timestamp of the keyframe
position (ndarray, shape (1, 3)) – Position value
in_cp (float) – The control point in case of using cubic Bézier interpolator when time exceeds this timestamp.
out_cp (float) – The control point in case of using cubic Bézier interpolator when time precedes this timestamp.
in_tangent (ndarray, shape (1, M), optional) – The in tangent at that position for the cubic spline curve.
out_tangent (ndarray, shape (1, M), optional) – The out tangent at that position for the cubic spline curve.
Notes
in_cp and out_cp only needed when using the cubic bezier interpolation method.
- set_position_interpolator(interpolator, is_evaluator=False, **kwargs)[source]#
Set the position interpolator.
- Parameters:
interpolator (callable) –
- The generator function of the interpolator that would handle the
position keyframes.
is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.
degree (int) – The degree of the spline interpolation in case of setting the spline_interpolator.
Examples
>>> Animation.set_position_interpolator(spline_interpolator, degree=5)
- set_position_keyframes(keyframes)[source]#
Set a dict of position keyframes at once. Should be in the following form: {timestamp_1: position_1, timestamp_2: position_2}
- Parameters:
keyframes (dict) – A dict with timestamps as keys and positions as values.
Examples
>>> pos_keyframes = {1, np.array([0, 0, 0]), 3, np.array([50, 6, 6])} >>> Animation.set_position_keyframes(pos_keyframes)
- set_rotation(timestamp, rotation, **kwargs)[source]#
Set a rotation keyframe at a specific timestamp.
- Parameters:
timestamp (float) – Timestamp of the keyframe
rotation (ndarray, shape(1, 3) or shape(1, 4)) – Rotation data in euler degrees with shape(1, 3) or in quaternions with shape(1, 4).
Notes
Euler rotations are executed by rotating first around Z then around X, and finally around Y.
- set_rotation_as_vector(timestamp, vector, **kwargs)[source]#
Set a rotation keyframe at a specific timestamp.
- Parameters:
timestamp (float) – Timestamp of the keyframe
vector (ndarray, shape(1, 3)) – Directional vector that describes the rotation.
- set_rotation_interpolator(interpolator, is_evaluator=False)[source]#
Set the rotation interpolator .
- Parameters:
interpolator (callable) – The generator function of the interpolator that would handle the rotation (orientation) keyframes.
is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.
Examples
>>> Animation.set_rotation_interpolator(slerp)
- set_scale(timestamp, scalar, **kwargs)[source]#
Set a scale keyframe at a specific timestamp.
- Parameters:
timestamp (float) – Timestamp of the keyframe
scalar (ndarray, shape(1, 3)) – Scale keyframe value associated with the timestamp.
- set_scale_interpolator(interpolator, is_evaluator=False)[source]#
Set the scale interpolator.
- Parameters:
interpolator (callable) – TThe generator function of the interpolator that would handle the scale keyframes.
is_evaluator (bool, optional) – Specifies whether the interpolator is time-only based evaluation function that does not depend on keyframes.
Examples
>>> Animation.set_scale_interpolator(step_interpolator)
- set_scale_keyframes(keyframes)[source]#
Set a dict of scale keyframes at once. Should be in the following form: {timestamp_1: scale_1, timestamp_2: scale_2}
- Parameters:
keyframes (dict) – A dict with timestamps as keys and scales as values.
Examples
>>> scale_keyframes = {1, np.array([1, 1, 1]), 3, np.array([2, 2, 3])} >>> Animation.set_scale_keyframes(scale_keyframes)
- property static_actors#
Return a list of static actors.
- Returns:
List of static actors.
- Return type:
- property timeline#
Return the Timeline handling the current animation.
- Returns:
The Timeline handling the current animation, None, if there is no associated Timeline.
- Return type:
- update_animation(time=None)[source]#
Update the animation.
Update the animation at a certain time. This will make sure all attributes are calculated and set to the actors at that given time.
Command
#
- fury.window.Command#
alias of
vtkCommand
CustomInteractorStyle
#
- class fury.window.CustomInteractorStyle[source]#
Bases:
vtkInteractorStyleUser
Manipulate the camera and interact with objects in the scene.
This interactor style allows the user to interactively manipulate (pan, rotate and zoom) the camera. It also allows the user to interact (click, scroll, etc.) with objects in the scene.
Several events handling methods from
vtkInteractorStyleUser
have been overloaded to allow the propagation of the events to the objects the user is interacting with.In summary, while interacting with the scene, the mouse events are as follows:
- Left mouse button: rotates the camera - Right mouse button: dollys the camera - Mouse wheel: dollys the camera - Middle mouse button: pans the camera
InTemporaryDirectory
#
- fury.window.InTemporaryDirectory#
alias of
TemporaryDirectory
InteractorEventRecorder
#
- fury.window.InteractorEventRecorder#
alias of
vtkInteractorEventRecorder
InteractorStyleImage
#
- fury.window.InteractorStyleImage#
alias of
vtkInteractorStyleImage
InteractorStyleTrackballCamera
#
- fury.window.InteractorStyleTrackballCamera#
alias of
vtkInteractorStyleTrackballCamera
OpenGLRenderer
#
- fury.window.OpenGLRenderer#
alias of
vtkOpenGLRenderer
RenderLargeImage
#
- fury.window.RenderLargeImage#
alias of
vtkRenderLargeImage
RenderWindow
#
- fury.window.RenderWindow#
alias of
vtkRenderWindow
RenderWindowInteractor
#
- fury.window.RenderWindowInteractor#
alias of
vtkRenderWindowInteractor
Scene
#
- class fury.window.Scene(background=(0, 0, 0), skybox=None)[source]#
Bases:
vtkOpenGLRenderer
Your scene class.
This is an important object that is responsible for preparing objects e.g. actors and volumes for rendering. This is a more pythonic version of
vtkRenderer
providing simple methods for adding and removing actors but also it provides access to all the functionality available invtkRenderer
if necessary.- azimuth(angle)[source]#
Rotate scene’s camera.
Rotate the camera about the view up vector centered at the focal point. Note that the view up vector is whatever was set via SetViewUp, and is not necessarily perpendicular to the direction of projection. The result is a horizontal rotation of the camera.
- camera_direction()[source]#
Get camera direction.
Get the vector in the direction from the camera position to the focal point. This is usually the opposite of the ViewPlaneNormal, the vector perpendicular to the screen, unless the view is oblique.
- dolly(value)[source]#
Dolly In/Out scene’s camera.
Divide the camera’s distance from the focal point by the given dolly value. Use a value greater than one to dolly-in toward the focal point, and use a value less than one to dolly-out away from the focal point.
- elevation(angle)[source]#
Elevate scene’s camera.
Rotate the camera about the cross product of the negative of the direction of projection and the view up vector, using the focal point as the center of rotation. The result is a vertical rotation of the scene.
- property last_render_time#
Returns the last render time in seconds.
- pitch(angle)[source]#
Pitch scene’s camera.
Rotate the focal point about the cross product of the view up vector and the direction of projection, using the camera’s position as the center of rotation. The result is a vertical rotation of the camera.
- projection(proj_type='perspective')[source]#
Decide between parallel or perspective projection.
- Parameters:
proj_type (str) – Can be ‘parallel’ or ‘perspective’ (default).
- reset_camera_tight(margin_factor=1.02)[source]#
Resets camera so the content fit tightly within the window.
- Parameters:
margin_factor (float (optional)) – Margin added around the content. Default: 1.02.
- roll(angle)[source]#
Roll scene’s camera.
Rotate the camera about the direction of projection. This will spin the camera about its axis.
- set_camera(position=None, focal_point=None, view_up=None)[source]#
Set up camera position / Focal Point / View Up.
- yaw(angle)[source]#
Yaw scene’s camera.
Rotate the focal point about the view up vector, using the camera’s position as the center of rotation. Note that the view up vector is whatever was set via SetViewUp, and is not necessarily perpendicular to the direction of projection. The result is a horizontal rotation of the scene.
ShowManager
#
- class fury.window.ShowManager(scene=None, title='FURY', size=(300, 300), png_magnify=1, reset_camera=True, order_transparent=False, interactor_style='custom', stereo='off', multi_samples=8, max_peels=4, occlusion_ratio=0.0)[source]#
Bases:
object
Class interface between the scene, the window and the interactor.
- __init__(scene=None, title='FURY', size=(300, 300), png_magnify=1, reset_camera=True, order_transparent=False, interactor_style='custom', stereo='off', multi_samples=8, max_peels=4, occlusion_ratio=0.0)[source]#
Manage the visualization pipeline.
- Parameters:
scene (Scene() or vtkRenderer()) – The scene that holds all the actors.
title (string) – A string for the window title bar.
size ((int, int)) –
(width, height)
of the window. Default is (300, 300).png_magnify (int) – Number of times to magnify the screenshot. This can be used to save high resolution screenshots when pressing ‘s’ inside the window.
reset_camera (bool) – Default is True. You can change this option to False if you want to keep the camera as set before calling this function.
order_transparent (bool) – True is useful when you want to order transparent actors according to their relative position to the camera. The default option which is False will order the actors according to the order of their addition to the Scene().
interactor_style (str or vtkInteractorStyle) – If str then if ‘trackball’ then vtkInteractorStyleTrackballCamera() is used, if ‘image’ then vtkInteractorStyleImage() is used (no rotation) or if ‘custom’ then CustomInteractorStyle is used. Otherwise you can input your own interactor style.
stereo (string) –
Set the stereo type. Default is ‘off’. Other types include:
’opengl’: OpenGL frame-sequential stereo. Referred to as ‘CrystalEyes’ by VTK.
’anaglyph’: For use with red/blue glasses. See VTK docs to use different colors.
’interlaced’: Line interlaced.
’checkerboard’: Checkerboard interlaced.
’left’: Left eye only.
’right’: Right eye only.
’horizontal’: Side-by-side.
multi_samples (int) – Number of samples for anti-aliazing (Default 8). For no anti-aliasing use 0.
max_peels (int) – Maximum number of peels for depth peeling (Default 4).
occlusion_ratio (float) – Occlusion ration for depth peeling (Default 0 - exact image).
- iren#
- Type:
vtkRenderWindowInteractor()
- style#
- Type:
vtkInteractorStyle()
- window#
- Type:
vtkRenderWindow()
Examples
>>> from fury import actor, window >>> scene = window.Scene() >>> scene.add(actor.axes()) >>> showm = window.ShowManager(scene) >>> # showm.render() >>> # showm.start()
- add_animation(animation)[source]#
Add an Animation or a Timeline to the ShowManager.
Adding an Animation or a Timeline to the ShowManager ensures that it gets added to the scene, gets updated and rendered without any extra code.
- property animations#
Return a list of Animations that were added to the ShowManager.
- property frame_rate#
Returns number of frames per second.
- play_events(events)[source]#
Play recorded events of a past interaction.
The VTK events that happened during the recorded interaction will be played back.
- Parameters:
events (str) – Recorded events (one per line).
- play_events_from_file(filename)[source]#
Play recorded events of a past interaction.
The VTK events that happened during the recorded interaction will be played back from filename.
- Parameters:
filename (str) – Name of the file containing the recorded events (.log|.log.gz).
- record_events()[source]#
Record events during the interaction.
The recording is represented as a list of VTK events that happened during the interaction. The recorded events are then returned.
- Returns:
events – Recorded events (one per line).
- Return type:
Notes
Since VTK only allows recording events to a file, we use a temporary file from which we then read the events.
- record_events_to_file(filename='record.log')[source]#
Record events during the interaction.
The recording is represented as a list of VTK events that happened during the interaction. The recording is going to be saved into filename.
- Parameters:
filename (str) – Name of the file that will contain the recording (.log|.log.gz).
- remove_animation(animation)[source]#
Remove an Animation or a Timeline from the ShowManager.
Animation will be removed from the Scene as well as from the ShowManager.
- save_screenshot(fname, magnification=1, size=None, stereo=None)[source]#
Save a screenshot of the current window in the specified filename.
- Parameters:
fname (str or None) – File name where to save the screenshot.
magnification (int, optional) – Applies a magnification factor to the scene before taking the screenshot which improves the quality. A value greater than 1 increases the quality of the image. However, the output size will be larger. For example, 200x200 image with magnification of 2 will result in a 400x400 image. Default is 1.
size (tuple of 2 ints, optional) – Size of the output image in pixels. If None, the size of the scene will be used. If magnification > 1, then the size will be determined by the magnification factor. Default is None.
stereo (str, optional) –
Set the type of stereo for the screenshot. Supported values are:
’opengl’: OpenGL frame-sequential stereo. Referred to as ‘CrystalEyes’ by VTK.
’anaglyph’: For use with red/blue glasses. See VTK docs to use different colors.
’interlaced’: Line interlaced.
’checkerboard’: Checkerboard interlaced.
’left’: Left eye only.
’right’: Right eye only.
’horizontal’: Side-by-side.
Skybox
#
- fury.window.Skybox#
alias of
vtkSkybox
Timeline
#
- class fury.window.Timeline(animations=None, playback_panel=False, loop=True, length=None)[source]#
Bases:
object
Keyframe animation Timeline.
Timeline is responsible for handling the playback of keyframes animations. It has multiple playback options which makes it easy to control the playback, speed, state of the animation with/without a GUI playback panel.
- animations#
Actor/s to be animated directly by the Timeline (main Animation).
- playback_panel#
If True, the timeline will have a playback panel set, which can be used to control the playback of the timeline.
- Type:
bool, optional
- length#
- the fixed length of the timeline. If set to None, the timeline will get
its length from the animations that it controls automatically.
- property animations: list[fury.animation.animation.Animation]#
Return a list of Animations.
- Returns:
List of Animations controlled by the timeline.
- Return type:
- property current_timestamp#
Get current timestamp of the Timeline.
- Returns:
The current time of the Timeline.
- Return type:
- property duration#
Return the duration of the Timeline.
- Returns:
The duration of the Timeline.
- Return type:
- property has_playback_panel#
Return whether the Timeline has a playback panel.
- Returns:
bool
- Return type:
‘True’ if the Timeline has a playback panel. otherwise, ‘False’
- property loop#
Get loop condition of the timeline.
- Returns:
Whether the playback is in loop mode (True) or play one mode (False).
- Return type:
- property paused#
Return whether the Timeline is paused.
- Returns:
True if the Timeline is paused.
- Return type:
- property playing#
Return whether the Timeline is playing.
- Returns:
True if the Timeline is playing.
- Return type:
- seek(timestamp)[source]#
Set the current timestamp of the Timeline.
- Parameters:
timestamp (float) – The time to seek.
- seek_percent(percent)[source]#
Seek a percentage of the Timeline’s final timestamp.
- Parameters:
percent (float) – Value from 1 to 100.
- property speed#
Return the speed of the timeline’s playback.
- Returns:
The speed of the timeline’s playback.
- Return type:
- property stopped#
Return whether the Timeline is stopped.
- Returns:
True if Timeline is stopped.
- Return type:
- update(force=False)[source]#
Update the timeline.
Update the Timeline and all the animations that it controls. As well as the playback of the Timeline (if exists).
- Parameters:
force (bool, optional, default: False) – If True, the timeline will update even when the timeline is paused or stopped and hence, more resources will be used.
Volume
#
- fury.window.Volume#
alias of
vtkVolume
WindowToImageFilter
#
- fury.window.WindowToImageFilter#
alias of
vtkWindowToImageFilter
basestring
#
analyze_scene#
analyze_snapshot#
- fury.window.analyze_snapshot(im, bg_color=(0.0, 0.0, 0.0), colors=None, find_objects=True, strel=None)[source]#
Analyze snapshot from memory or file.
- Parameters:
im (str or array) – If string then the image is read from a file otherwise the image is read from a numpy array. The array is expected to be of shape (X, Y, 3) or (X, Y, 4) where the last dimensions are the RGB or RGBA values.
colors (tuple (3,) or list of tuples (3,)) – List of colors to search in the image
find_objects (bool) – If True it will calculate the number of objects that are different from the background and return their position in a new image.
strel (2d array) – Structure element to use for finding the objects.
- Returns:
report – This is an object with attibutes like
colors_found
that give information about what was found in the current snapshot arrayim
.- Return type:
ReportSnapshot
antialiasing#
- fury.window.antialiasing(scene, win, multi_samples=8, max_peels=4, occlusion_ratio=0.0)[source]#
Enable anti-aliasing and ordered transparency.
- Parameters:
scene (Scene) –
win (Window) – Provided by ShowManager.window attribute.
multi_samples (int) – Number of samples for anti-aliasing (Default 8). For no anti-aliasing use 0.
max_peels (int) – Maximum number of peels for depth peeling (Default 4).
occlusion_ratio (float) – Occlusion ratio for depth peeling (Default 0 - exact image).
asbytes#
enable_stereo#
- fury.window.enable_stereo(renwin, stereo_type)[source]#
Enable the given stereo type on the RenderWindow.
- Parameters:
renwin (vtkRenderWindow) –
stereo_type (string) –
‘opengl’: OpenGL frame-sequential stereo. Referred to as ‘CrystalEyes’ by VTK.
’anaglyph’: For use with red/blue glasses. See VTK docs to use different colors.
’interlaced’: Line interlaced.
’checkerboard’: Checkerboard interlaced.
’left’: Left eye only.
’right’: Right eye only.
’horizontal’: Side-by-side.
gl_disable_blend#
gl_disable_depth#
gl_enable_blend#
gl_enable_depth#
gl_get_current_state#
gl_reset_blend#
gl_set_additive_blending#
gl_set_additive_blending_white_background#
gl_set_multiplicative_blending#
gl_set_normal_blending#
gl_set_subtractive_blending#
load_image#
record#
- fury.window.record(scene=None, cam_pos=None, cam_focal=None, cam_view=None, out_path=None, path_numbering=False, n_frames=1, az_ang=10, magnification=1, size=(300, 300), reset_camera=True, screen_clip=False, stereo='off', verbose=False)[source]#
Record a video of your scene.
Records a video as a series of
.png
files of your scene by rotating the azimuth angle az_angle in every frame.- Parameters:
cam_pos (None or sequence (3,), optional) – Camera’s position. If None then default camera’s position is used.
cam_focal (None or sequence (3,), optional) – Camera’s focal point. If None then default camera’s focal point is used.
cam_view (None or sequence (3,), optional) – Camera’s view up direction. If None then default camera’s view up vector is used.
out_path (str, optional) – Output path for the frames. If None a default fury.png is created.
path_numbering (bool) – When recording it changes out_path to out_path + str(frame number)
n_frames (int, optional) – Number of frames to save, default 1
az_ang (float, optional) – Azimuthal angle of camera rotation.
magnification (int, optional) – How much to magnify the saved frame. Default is 1. A value greater than 1 increases the quality of the image. However, the output size will be larger. For example, 200x200 image with magnification of 2 will be a 400x400 image.
size ((int, int)) –
(width, height)
of the window. Default is (300, 300).screen_clip (bool) – Clip the png based on screen resolution. Default is False.
reset_camera (bool) –
- If True Call
scene.reset_camera()
. Otherwise you need to set the camera before calling this function.
- If True Call
stereo (string) –
Set the stereo type. Default is ‘off’. Other types include:
’opengl’: OpenGL frame-sequential stereo. Referred to as ‘CrystalEyes’ by VTK.
’anaglyph’: For use with red/blue glasses. See VTK docs to use different colors.
’interlaced’: Line interlaced.
’checkerboard’: Checkerboard interlaced.
’left’: Left eye only.
’right’: Right eye only.
’horizontal’: Side-by-side.
verbose (bool) – print information about the camera. Default is False.
Examples
>>> from fury import window, actor >>> scene = window.Scene() >>> a = actor.axes() >>> scene.add(a) >>> # uncomment below to record >>> # window.record(scene) >>> # check for new images in current directory
save_image#
- fury.window.save_image(arr, filename, compression_quality=75, compression_type='deflation', use_pillow=True, dpi=(72, 72))[source]#
Save a 2d or 3d image.
Expect an image with the following shape: (H, W) or (H, W, 1) or (H, W, 3) or (H, W, 4).
- Parameters:
arr (ndarray) – array to save
filename (string) – should be png, bmp, jpeg or jpg files
compression_quality (int, optional) – compression_quality for jpeg data. 0 = Low quality, 100 = High quality
compression_type (str, optional) – compression type for tiff file select between: None, lzw, deflation (default)
use_pillow (bool, optional) – Use imageio python library to save the files.
dpi (float or (float, float)) – Dots per inch (dpi) for saved image. Single values are applied as dpi for both dimensions.
show#
- fury.window.show(scene, title='FURY', size=(300, 300), png_magnify=1, reset_camera=True, order_transparent=False, stereo='off', multi_samples=8, max_peels=4, occlusion_ratio=0.0)[source]#
Show window with current scene.
- Parameters:
scene (Scene() or vtkRenderer()) – The scene that holds all the actors.
title (string) – A string for the window title bar. Default is FURY and current version.
size ((int, int)) –
(width, height)
of the window. Default is (300, 300).png_magnify (int) – Number of times to magnify the screenshot. Default is 1. This can be used to save high resolution screenshots when pressing ‘s’ inside the window.
reset_camera (bool) – Default is True. You can change this option to False if you want to keep the camera as set before calling this function.
order_transparent (bool) – True is useful when you want to order transparent actors according to their relative position to the camera. The default option which is False will order the actors according to the order of their addition to the Scene().
stereo (string) –
Set the stereo type. Default is ‘off’. Other types include:
’opengl’: OpenGL frame-sequential stereo. Referred to as ‘CrystalEyes’ by VTK.
’anaglyph’: For use with red/blue glasses. See VTK docs to use different colors.
’interlaced’: Line interlaced.
’checkerboard’: Checkerboard interlaced.
’left’: Left eye only.
’right’: Right eye only.
’horizontal’: Side-by-side.
multi_samples (int) – Number of samples for anti-aliazing (Default 8). For no anti-aliasing use 0.
max_peels (int) – Maximum number of peels for depth peeling (Default 4).
occlusion_ratio (float) – Occlusion ration for depth peeling (Default 0 - exact image).
Examples
>>> import numpy as np >>> from fury import window, actor >>> r = window.Scene() >>> lines=[np.random.rand(10,3),np.random.rand(20,3)] >>> colors=np.array([[0.2,0.2,0.2],[0.8,0.8,0.8]]) >>> c=actor.line(lines,colors) >>> r.add(c) >>> l=actor.label(text="Hello") >>> r.add(l) >>> #window.show(r)
See also
snapshot#
- fury.window.snapshot(scene, fname=None, size=(300, 300), offscreen=True, order_transparent=False, stereo='off', multi_samples=8, max_peels=4, occlusion_ratio=0.0, dpi=(72, 72))[source]#
Save a snapshot of the scene in a file or in memory.
- Parameters:
scene (Scene() or vtkRenderer) – Scene instance
fname (str or None) – Save PNG file. If None return only an array without saving PNG.
size ((int, int)) –
(width, height)
of the window. Default is (300, 300).offscreen (bool) – Default True. Go stealth mode no window should appear.
order_transparent (bool) – Default False. Use depth peeling to sort transparent objects. If True also enables anti-aliasing.
stereo (string) –
Set the stereo type. Default is ‘off’. Other types include:
’opengl’: OpenGL frame-sequential stereo. Referred to as ‘CrystalEyes’ by VTK.
’anaglyph’: For use with red/blue glasses. See VTK docs to use different colors.
’interlaced’: Line interlaced.
’checkerboard’: Checkerboard interlaced.
’left’: Left eye only.
’right’: Right eye only.
’horizontal’: Side-by-side.
multi_samples (int) – Number of samples for anti-aliazing (Default 8). For no anti-aliasing use 0.
max_peels (int) – Maximum number of peels for depth peeling (Default 4).
occlusion_ratio (float) – Occlusion ration for depth peeling (Default 0 - exact image).
dpi (float or (float, float)) – Dots per inch (dpi) for saved image. Single values are applied as dpi for both dimensions.
- Returns:
arr – Color array of size (width, height, 3) where the last dimension holds the RGB values.
- Return type:
ndarray
warn#
- fury.window.warn(message, category=None, stacklevel=1, source=None)#
Issue a warning, or maybe ignore it or raise an exception.