-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,203 changed files
with
499,871 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v0.9.x | ||
v0.10.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: f947d0e99c572b4dcff0ce6cdbeab40d | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
237 changes: 237 additions & 0 deletions
237
v0.10.x/_downloads/02506d9d0821045a7f391bb7d1e4dd02/viz_spline_interpolator.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n# Keyframes Spline Interpolator\n\nTutorial on making keyframe-based animation in FURY using Spline interpolators.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n\nfrom fury import actor, window\nfrom fury.animation import Animation, Timeline\nfrom fury.animation.interpolator import spline_interpolator\n\nscene = window.Scene()\n\nshowm = window.ShowManager(\n scene, size=(900, 768), reset_camera=False, order_transparent=True\n)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Position keyframes as a dict object containing timestamps as keys and\npositions as values.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"position_keyframes = {\n 0.0: np.array([0, 0, 0]),\n 2.0: np.array([10, 3, 5]),\n 4.0: np.array([20, 14, 13]),\n 6.0: np.array([-20, 20, 0]),\n 8.0: np.array([17, -10, 15]),\n 10.0: np.array([0, -6, 0]),\n}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"creating FURY dots to visualize the position values.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"pos_dots = actor.dot(np.array(list(position_keyframes.values())))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"creating two timelines (one uses linear and the other uses' spline\ninterpolator), each timeline controls a sphere actor\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"sphere_linear = actor.sphere(np.array([[0, 0, 0]]), (1, 0.5, 0.2), 0.5)\n\nlinear_anim = Animation()\nlinear_anim.add_actor(sphere_linear)\n\nlinear_anim.set_position_keyframes(position_keyframes)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Note: linear_interpolator is used by default. So, no need to set it for this\nfirst animation that we need to linearly interpolate positional animation.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"creating a second timeline that translates another larger sphere actor using\nspline interpolator.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"sphere_spline = actor.sphere(np.array([[0, 0, 0]]), (0.3, 0.9, 0.6), 1)\nspline_anim = Animation(sphere_spline)\nspline_anim.set_position_keyframes(position_keyframes)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Setting 5th degree spline interpolator for position keyframes.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"spline_anim.set_position_interpolator(spline_interpolator, degree=5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Wrapping animations up!\n\nAdding everything to a ``Timeline`` to control the two timelines.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"First we create a timeline with a playback panel:\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"timeline = Timeline(playback_panel=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Add visualization dots actor to the scene.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"scene.add(pos_dots)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Adding the animations to the timeline (so that it controls their playback).\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"timeline.add_animation([linear_anim, spline_anim])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Adding the timeline to the show manager.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"showm.add_animation(timeline)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now that these two animations are added to timeline, if the timeline\nis played, paused, ..., all these changes will reflect on the animations.\n\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"interactive = False\n\nif interactive:\n showm.start()\n\nwindow.record(scene, out_path='viz_keyframe_animation_spline.png', size=(900, 768))" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
70 changes: 70 additions & 0 deletions
70
v0.10.x/_downloads/047960bb41f51d256e795f60be8e1969/viz_timers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
=============== | ||
Using a timer | ||
=============== | ||
This example shows how to create a simple animation using a timer callback. | ||
We will use a sphere actor that generates many spheres of different colors, | ||
radii and opacity. Then we will animate this actor by rotating and changing | ||
global opacity levels from inside a user defined callback. | ||
The timer will call this user defined callback every 200 milliseconds. The | ||
application will exit after the callback has been called 100 times. | ||
""" | ||
|
||
|
||
import itertools | ||
|
||
import numpy as np | ||
|
||
from fury import actor, ui, window | ||
|
||
xyz = 10 * np.random.rand(100, 3) | ||
colors = np.random.rand(100, 4) | ||
radii = np.random.rand(100) + 0.5 | ||
|
||
scene = window.Scene() | ||
|
||
sphere_actor = actor.sphere(centers=xyz, colors=colors, radii=radii) | ||
|
||
scene.add(sphere_actor) | ||
|
||
showm = window.ShowManager( | ||
scene, size=(900, 768), reset_camera=False, order_transparent=True | ||
) | ||
|
||
|
||
tb = ui.TextBlock2D(bold=True) | ||
|
||
# use itertools to avoid global variables | ||
counter = itertools.count() | ||
|
||
|
||
def timer_callback(_obj, _event): | ||
global timer_id | ||
cnt = next(counter) | ||
tb.message = "Let's count up to 300 and exit :" + str(cnt) | ||
showm.scene.azimuth(0.05 * cnt) | ||
sphere_actor.GetProperty().SetOpacity(cnt / 100.0) | ||
showm.render() | ||
|
||
if cnt == 10: | ||
# destroy the first timer and replace it with another faster timer | ||
showm.destroy_timer(timer_id) | ||
timer_id = showm.add_timer_callback(True, 10, timer_callback) | ||
|
||
if cnt == 300: | ||
# destroy the second timer and exit | ||
showm.destroy_timer(timer_id) | ||
showm.exit() | ||
|
||
|
||
scene.add(tb) | ||
|
||
# Run every 200 milliseconds | ||
timer_id = showm.add_timer_callback(True, 200, timer_callback) | ||
|
||
showm.start() | ||
|
||
window.record(showm.scene, size=(900, 768), out_path='viz_timer.png') |
Oops, something went wrong.