Reference navigation
On this page
Animation
Base class for animations evaluated by the scene timeline.
from proteinmotion.animation import AnimationConstructor
Animation(target, *, rate_func=smooth, easing=None)Parameters
| Parameter | Default | Description |
|---|---|---|
target | Required | Object to animate or use as a destination. The supported object type depends on the operation. |
rate_funckeyword only | smooth | Callable that maps progress in [0, 1] to a finite value in [0, 1]. |
easingkeyword only | None | Named easing (smooth, linear, ease_in_out_sine, there_and_back) or callable mapping [0, 1] to [0, 1]. Per-item easing preserves stagger timing. |
Notes
Subclass Animation to define a custom animation. Declare the channels it changes, capture starting values in bind(), and implement apply(alpha). The scene rejects simultaneous writes to the same channel.
Attributes
| Name | Description |
|---|---|
channels | Set of state channels written by the animation. |
target | Primary target object. |
rate_func | Progress easing callable. |
Methods and properties
| Name | Description |
|---|---|
| during()method | Set this animation duration and start delay in seconds. |
| bind()method | Capture starting values when the scene schedules the animation. |
| targetsproperty | Objects whose state this animation changes. |
| apply()method | Evaluate the animation at eased progress alpha. Called by the timeline. |
Animation.during(seconds, *, delay=0)Set this animation duration and start delay in seconds.
| Parameter | Default | Description |
|---|---|---|
seconds | Required | Positive animation duration in seconds. |
delaykeyword only | 0 | Nonnegative animation start delay in seconds. |
Animation.bind()Capture starting values when the scene schedules the animation.
Returns: None
Called by ProteinScene.play(). An animation instance can be bound once.
Animation.targetsObjects whose state this animation changes.
Animation.apply(alpha)Evaluate the animation at eased progress alpha. Called by the timeline.
| Parameter | Default | Description |
|---|---|---|
alpha | Required | Eased animation progress in [0, 1]. |
Returns: None