ProteinMotion
Reference navigation
On this page

Animation

Base class for animations evaluated by the scene timeline.

python
from proteinmotion.animation import Animation

Constructor

python
Animation(target, *, rate_func=smooth, easing=None)

Parameters

ParameterDefaultDescription
targetRequiredObject to animate or use as a destination. The supported object type depends on the operation.
rate_funckeyword onlysmoothCallable that maps progress in [0, 1] to a finite value in [0, 1].
easingkeyword onlyNoneNamed 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

NameDescription
channelsSet of state channels written by the animation.
targetPrimary target object.
rate_funcProgress easing callable.

Methods and properties

NameDescription
during()methodSet this animation duration and start delay in seconds.
bind()methodCapture starting values when the scene schedules the animation.
targetspropertyObjects whose state this animation changes.
apply()methodEvaluate the animation at eased progress alpha. Called by the timeline.
python
Animation.during(seconds, *, delay=0)

Set this animation duration and start delay in seconds.

ParameterDefaultDescription
secondsRequiredPositive animation duration in seconds.
delaykeyword only0Nonnegative animation start delay in seconds.
python
Animation.bind()

Capture starting values when the scene schedules the animation.

Returns: None

Called by ProteinScene.play(). An animation instance can be bound once.

python
Animation.targets

Objects whose state this animation changes.

python
Animation.apply(alpha)

Evaluate the animation at eased progress alpha. Called by the timeline.

ParameterDefaultDescription
alphaRequiredEased animation progress in [0, 1].

Returns: None