animation_contexts

Animation contexts – the with blocks that decide when things happen.

Recording an animation says what changes; the surrounding context says how the changes are laid out in time. There are four:

Seq

One after another. The default outside any context.

Sync

All at once.

Lag

Overlapping – each change starts when the previous is ratio of the way through. Lag(0) is Sync, Lag(1) is Seq.

Off

Instantly, in a single frame, recording no animation.

Contexts nest, and a nested context counts as a single animation to its parent, which is what makes complex multi-Mob choreography readable. Unset parameters are inherited from the enclosing context. runtime sets a context’s total runtime and is applied retroactively on __exit__, by rescaling every child timestamp – which is why an event recorded outside any entered-and-exited context evaluates to time zero.

Audio and Speech are the same mechanism with their runtime taken from a sound clip instead of a number.

AnimationManager is the per-Scene owner of the context stack.

See Combining Animations.

Classes

AnimationContext

Base class for the with blocks that control animation timing.

AnimationManager

Per-Scene owner of the active animation-context stack.

Audio

Play a sound, and fit the block's animations to its length.

ComposedEasing

Bend the timing of the block's animations through an extra rate function.

Lag

Overlap the block's animations, each starting partway into the last.

NoExtra

Suppress enclosing contexts' spawn/despawn extras inside this block.

Off

Apply changes instantly, with no animation and no video time.

OnInit

Run a function over every Mob constructed inside the block.

Seq

Play the block's animations one after another.

SlideShow

Present Mobs one at a time, pausing on each, and clear up at the end.

Speech

Narrate a line, and fit the block's animations to how long it takes to say.

Sync

Play the block's animations all at the same time.

Functions

active_scene_for_new_mob()[source]

Return the SceneManager’s current active scene.

animation_manager_bound(function)[source]

Run an initialized Animatable method with its Scene manager bound.

animation_manager_context(animation_manager)[source]

Temporarily bind implicit AnimationContexts to one scene manager.

animation_manager_for(*owners)[source]

Resolve the one animation manager associated with owners.

Owners may be scenes, mobs, or nested Python collections containing them. A context cannot coherently combine mobs from different scenes, so mixed managers are rejected instead of silently recording into whichever scene happens to be globally active.