plushie/animation
Animation helpers for frame-based interpolation.
Use with subscription.on_animation_frame to drive updates.
Create an animation with new, start it, then advance each frame.
Types
An animation interpolating between two values over time.
pub type Animation {
Animation(
from: Float,
to: Float,
duration_ms: Int,
started_at: option.Option(Int),
easing: Easing,
value: Float,
finished: Bool,
)
}
Constructors
-
Animation( from: Float, to: Float, duration_ms: Int, started_at: option.Option(Int), easing: Easing, value: Float, finished: Bool, )
Values
pub fn advance(anim: Animation, now: Int) -> Animation
Advance the animation to the given timestamp. Returns updated animation.
Check finished field to know when it’s done.
pub fn apply_easing(easing: Easing, t: Float) -> Float
Apply an easing function to a progress value (0.0 to 1.0).
pub fn lerp(from: Float, to: Float, t: Float) -> Float
Linear interpolation between two values.
pub fn new(
from: Float,
to: Float,
duration_ms: Int,
easing: Easing,
) -> Animation
Create a new animation (not yet started).