AnimationContext¶
Qualified name: algan.animation.animation\_contexts.AnimationContext
- class AnimationContext(*, run_time=None, run_time_unit=None, same_run_time=None, lag_ratio=None, priority_level=None, rate_func=None, rate_func_compose=None, combine_rate_func=False, record_funcs=None, record_attr_modifications=None, prev_context=None, spawn_at_end=None, new_animation=False, finished=False, trace_mode=None, traced_mobs=<factory>, new_mobs=<factory>, child_contexts=<factory>, kwargs=<factory>)[source]¶
Bases:
object
An AnimationContext is a context manager that defines how animated_functions that occur within its context should be combined and scaled when creating the final animation timeline. Roughly speaking, an AnimationContext combines all of the
animated_function()
s that take place within its context into a singleanimated_function()
that plays all of the component animations one after the other.AnimationContexts are designed to be nested, in order to make defining complex animation behaviours easy. When creating a new AnimationContext inside of an existing one, any parameters which are None will inherit their value from the parent context. Parameters with a non-None value will override the parent’s value for the new context.
- Parameters:
run_time (float | None) – If not None, then this context will have its duration be rescaled to run_time, otherwise run_time is defined by the component animations that take place in this context.
run_time_unit (float | None) – The duration that each component animation within this context will run for. Uf run_time is not None, then run_time overrides run_time_unit.
same_run_time (bool | None) – If True, rescale all component animations to have the same run_time (equal to the longest component run time).
lag_ratio (float | None) – The portion of run_time_unit that will be waited for before starting the next component animation. When lag_ratio=0, all component animations are played at the same time, when lag_ratio=1, component animations are played one after the other immediately after the previous finishes.
priority_level (float | None) – The priority level of this context. AnimationContexts can only be overridden by new AnimationContexts of equal or higher priority.
rate_func (Callable[[], float] | None) – The rate function defines the rate at which time progresses for each component animation. Defaults to smooth. Setting this parameter overrides the parent context’s rate_func to be equal to this value.
rate_func_compose (Callable[[], float] | None) – Setting this parameter sets the rate_func to be the composition of the parent context’s rate_func with this rate_func_compose.
record_funcs (bool | None) – Whether
animated_function()
s within this context should be recorded inModificationHistory
s.record_attr_modifications (bool | None) – Whether changes to animatable_attributes within this context should be recorded in
ModificationHistory
s.prev_context (
AnimationContext
) – The parent context in which this AnimationContext was created.spawn_at_end (bool | None) – If True, all new
Mob
s created in this context will be prevented from spawning, until the end of this context where they will all be spawned.combine_rate_func (bool)
new_animation (bool | None)
finished (bool)
trace_mode (bool | None)
traced_mobs (set)
new_mobs (list)
child_contexts (list)
kwargs (Any)
Methods
add_child_context
add_mob
get_current_end_time
get_current_time
get_descendants
get_end_time
get_rescaled
get_rescaling_time
increment_times
on_create
on_create_extra
on_destroy
on_destroy_extra
on_init
on_init_extra
rewind
wait
Attributes
combine_rate_func
finished
lag_ratio
new_animation
prev_context
priority_level
rate_func
rate_func_compose
record_attr_modifications
record_funcs
run_time
run_time_unit
same_run_time
spawn_at_end
trace_mode
traced_mobs
new_mobs
child_contexts
kwargs