Animatable¶
Qualified name: algan.animation.animatable.Animatable
- class Animatable(scene=None, add_to_scene=True, name='_', init=True, animation_manager=None, data=None, data_sub_inds=None, parent_batch_sizes=None, is_primitive=False)[source]¶
Bases:
object
Base class for anything that needs animation.
- Parameters:
scene (Scene | None) – The Scene to which this animatable should (possibly) be added.
add_to_scene (bool) – Whether this animatable should be added to the scene.
name (str) – The name of this animatable.
init (bool) – Whether this animatable should be initialized.
animation_manager (AnimationManager | None) – The AnimationManager that will control animations applied to this animatable.
data (AnimatableData | None) – The AnimatableData which will record animatable attribute values for this animatable.
data_sub_inds (Tensor | None) – Specifies which indexes in data dictionaries this animatable will read and write from. Used to implement multiple sub-mobs which all share the same underlying data tensors, for batching purposes.
parent_batch_sizes (Tensor | None) – If this animatable’s parent is batched, parent_batch_sizes specifies how the parent’s attribute modifications will be expanded for this animatable’s attributes.
is_primitive (bool) – Whether this animatable is a rendering primitive, i.e. needs to be kept around at rendering time.
- animatable_attrs¶
A set of attribute names which will be treated as animatable. When ever an animatable attribute is modified, it will be treated as applying an animated function to this mob.
- Type:
Set[String]
Methods
Adds a collection of mobs to this mob's list of children, thereby propagating attribute changes made to the parent to the children.
Adds a function to this Mob's collection of updaters.
Animates the application of function, interpolating its animated parameter from 0 to t.
Same as
animate_function()
but the animation parameter is equal to time elapsed since starting the animation, instead of interpolating 0 to t over the animation duration.clone
delete
despawn
generate_animatable_attr_set_get_methods
get_default_color
getattr_at_time_t
getattribute_animated
getattribute_animated_full
identity
init
is_animating
on_create
on_destroy
on_init
remove_all_passive_animations
remove_child
Removes the specified updater from this mobs updater, leaving the mob with whatever state the updater left it with at the time-stamp when it was removed.
reset_state
set_parent_to
Sets all animatable attribute values to their final values after animated_functions have been applied.
Sets all animatable attribute values to the values they had before any animated_function applications take place.
set_state_to_time_all
set_state_to_time_t
set_to_current
set_to_retroactive
setattr_and_record_modification
Spawns the mob, introducing it into the video.
to
update_gather_scatter_inds
An animated function that does nothing for one second!
Attributes
animation_manager
- add_children(*mobs)[source]¶
Adds a collection of mobs to this mob’s list of children, thereby propagating attribute changes made to the parent to the children.
- add_updater(update_function, *args, **kwargs)[source]¶
Adds a function to this Mob’s collection of updaters. During animation, at every frame all of the Mob’s updaters are executed, with the time elapsed since being added (in seconds) passed as the second parameter to each updater. Useful for implementing permanent or ‘idle’ animations.
- Parameters:
update_function – The function which will be called every frame. It must accept a Mob as its first parameter and a float as its second parameter. During animation it will be called with this mob as the first parameter and the time elapsed (in seconds) as the second parameter.
*args – Passed to update_function.
**kwargs – Passed to update_function.
- Returns:
An integer ID identifying the updater that was added. This ID can be used to remove
the updater at a later time, using
remove_updater()
. – If it is never ignored, the updater will continue forever.
- animate_function(function, t=1, *args, **kwargs)[source]¶
Animates the application of function, interpolating its animated parameter from 0 to t.
- Parameters:
function – The function to animate. It must accept a mob as its first parameter, and a float as its second parameter. During the animation, the second parameter will be interpolated from 0 to t.
t – The final value that the animated parameter will have at the end of the animation.
*args – Passed to function.
**kwargs – Passed to function.
- animate_function_of_time(function, time_elapsed=0, *args, **kwargs)[source]¶
Same as
animate_function()
but the animation parameter is equal to time elapsed since starting the animation, instead of interpolating 0 to t over the animation duration. This formulation can be useful when you don’t know how long an animation will play for, and you want it to play indefinitely.- Parameters:
function – The function to animate. It must accept a mob as its first parameter, and a float as its second parameter. During the animation, the second parameter will range from 0 to the duration of the animation (in seconds).
time_elapsed – Dummy parameter. No matter what value you give it, it will be overwritten with the time elapsed since the animation beginning.
*args – Passed to function.
**kwargs – Passed to function.
- remove_updater(updater_id)[source]¶
Removes the specified updater from this mobs updater, leaving the mob with whatever state the updater left it with at the time-stamp when it was removed.
- Parameters:
updater_id – The identifier of the updater to be removed. Can be given a value of -1 to remove the most recently added updater.
- set_state_full(s, e)[source]¶
Sets all animatable attribute values to their final values after animated_functions have been applied.
- set_state_pre_function_applications(spawn_ind, despawn_ind)[source]¶
Sets all animatable attribute values to the values they had before any animated_function applications take place.
- spawn(animate=True)[source]¶
Spawns the mob, introducing it into the video. Prior to spawning, a Mob will not appear on screen and any changes made to its animatable attributes will not be animated. After spawning, changes made to the Mob are animated by default.
- Parameters:
animate (bool) – Whether a spawn-in animation should be played. By default, the spawn-in animation is a simple fade-in. Defaults to True.