Skip to main content

Crate animato

Crate animato 

Source
Expand description

§Animato

Italian: animato — animated, lively, with life and movement.

A professional-grade, renderer-agnostic animation library for Rust. Zero mandatory dependencies. no_std-ready.

Works everywhere: TUIs, Web (WASM), Bevy games, embedded targets, and native apps.

§Quick Start

use animato::{Tween, Easing, Update};

let mut tween = Tween::new(0.0_f32, 100.0)
    .duration(1.0)
    .easing(Easing::EaseOutCubic)
    .build();

tween.update(1.0);
assert_eq!(tween.value(), 100.0);
assert!(tween.is_complete());

§Spring Physics

use animato::{Spring, SpringConfig, Update};

let mut spring = Spring::new(SpringConfig::wobbly());
spring.set_target(200.0);

while !spring.is_settled() {
    spring.update(1.0 / 60.0);
}
assert!((spring.position() - 200.0).abs() < 0.01);

§Input Physics

use animato::{Inertia, InertiaConfig, Update};

let mut inertia = Inertia::new(InertiaConfig::smooth());
inertia.kick(800.0);
while inertia.update(1.0 / 60.0) {}

§AnimationDriver

use animato::{Tween, Easing, AnimationDriver, WallClock, Clock};

let mut driver = AnimationDriver::new();
let id = driver.add(
    Tween::new(0.0_f32, 1.0).duration(2.0).easing(Easing::EaseInOutSine).build()
);

let mut clock = WallClock::new();
// In your loop: driver.tick(clock.delta());

§no_std Usage

For no_std targets, depend on the sub-crates directly:

[dependencies]
animato-core   = { version = "0.7", default-features = false }
animato-tween  = { version = "0.7", default-features = false }
animato-spring = { version = "0.7", default-features = false }
animato-physics = { version = "0.7", default-features = false }
animato-color = { version = "0.7", default-features = false }

§Feature Flags

FeatureWhat it adds
defaultstd + tween + timeline + spring + driver
stdWall clock, heap-backed types
tweenTween<T>, KeyframeTrack<T>, Loop
timelineTimeline, Sequence, stagger()
springSpring, SpringConfig, SpringN<T>
path[MotionPath], [MotionPathTween], [SvgPathParser]
physics[Inertia], [DragState], [GestureRecognizer]
color[InLab<T>], [InOklch<T>], [InLinear<T>]
driverAnimationDriver, all Clock variants
bevy[AnimatoPlugin], Bevy tween/spring wrapper components
wasm[RafDriver] for requestAnimationFrame loops
tokio[Timeline::wait()] async completion waiting
serdeSerialize/Deserialize on all public types

Modules§

easing
All free easing functions (ease_out_cubic, cubic_bezier, etc.) re-exported at crate root.
stagger
Stagger helper for offsetting many animations.

Structs§

AnimationDriver
Manages a collection of animations, ticking them each frame and automatically removing completed ones.
AnimationId
An opaque handle to an animation registered with AnimationDriver.
Keyframe
A value sample in a KeyframeTrack.
KeyframeTrack
A sorted collection of keyframes that evaluates a value over time.
ManualClock
A clock where the caller explicitly sets the dt each frame.
MockClock
A fixed-step clock for deterministic tests.
ScrollClock
A Clock implementation backed by scroll-position changes.
ScrollDriver
Drives registered animations from a normalised scroll position.
Sequence
Builder for timeline entries that play one after another.
Spring
A 1D damped harmonic oscillator spring.
SpringConfig
Configuration for a damped harmonic oscillator spring.
SpringN
A multi-dimensional spring that animates any type that can be decomposed into independent f32 components (see the sealed Decompose trait).
Timeline
Composes multiple animations on one shared clock.
Tween
A single-value animation from start to end over duration seconds.
TweenBuilder
Consuming builder for Tween<T>.
WallClock
A real-time clock backed by std::time::Instant.

Enums§

At
Positioning rule for a timeline entry.
Easing
All 31 classic easing variants, CSS-compatible parameterized variants, and an escape-hatch Custom function pointer.
Integrator
Integration method for the spring ODE.
Loop
Controls how a tween behaves when it reaches the end of its duration.
TimelineState
Current playback state of a Timeline.
TweenState
The current execution state of a Tween.

Traits§

Animatable
Marker trait for types that can be used as animation targets.
Clock
Abstracts any time source that can produce a dt (delta-time) value in seconds.
Interpolate
A value that supports linear interpolation between two instances.
Playable
Object-safe animation interface used by composition containers.
Update
A value that advances through time.

Functions§

round_to
Round a value to a given number of decimal places.
snap_to
Snap a value to the nearest multiple of grid.
stagger
Create a timeline where each animation starts delay seconds after the previous one.