🎞️ animate
Lightweight Rust animation library with tweening and physics-based springs

Features
- Lightweight: Zero dependencies by default.
- Ergonomic: Macro-driven API with minimal boilerplate.
- Extensible: Many built-in types with support for custom interpolators.
- Animation modes:
once,cycle,alternate. - Easing: Built-in and custom easing functions.
- Physics-based: Supports spring animations.
- Ratatui-friendly: Interpolators for ratatui types, gated behind the
ratatuifeature flag.
Installation
Getting started
Add #[animate] to a struct and mark the fields you want to animate:
By default the macro generates an update method named animate. It must be called at the top of your struct's render method.
If the name conflicts with an existing method, rename it:
Next, place animate::tick() before your struct's update call at the start of each frame:
let mut widget = new;
loop
Use get() to read and set() to write animated fields.
Minimal example
use animate;
use ;
Animation modes
| Mode value | Behaviour |
|---|---|
"once" |
Animates to target once, then holds. |
"cycle" |
Loops continuously from start to target. |
"alternate" |
Ping-pongs back and forth between start and target. |
Fields
| Option | Type | Default | Description |
|---|---|---|---|
duration |
u64 (ms) |
0 |
Animation duration in milliseconds. |
easing |
path | linear |
Easing function (fn(f64) -> f64). |
interp |
path | <T as Lerp>::lerp |
Interpolation function (fn(&T, &T, f64) -> T). |
Built-in easing functions
linear, quad_in, quad_out, quad_in_out,
cubic_in, cubic_out, cubic_in_out
Spring animations
In addition to time-based animations, or Tweens, animate also supports physics-based spring animations.
Custom types