🎞️ animate
Animation Library for Rust.

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], and#[alternate]. - Easing: Built-in and custom easing functions.
- 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
| Attribute | 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
All mode attributes accept the same options:
| 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
Custom types
Implement Lerp for any type: