celerity
Buttery smooth animation toolkit.
Overview
Celerity implements primitives for precise animation of arbitrary value types.
Celerity is largely compatible with the animation model of Adobe After Effects, relying on Cubic Beziers for both temporal and spatial easing. After Effects animations exported using the bodymovin
plugin can be imported into celerity. This is very similar to the Lottie web animation framework.
Example
TODO
Traits
Celerity centers on a few traits:
trait Animatable
- A value type that can be used for animation keyframes. Must be able tolerp(...)
(linear interpolation) and measure shortestdistance_to()
between two values A and B.C
is the type of the scalar components (e.g.f32
).trait Animation<V>
- A time-changing valueV
that you cansample(...)
at any point in time.trait BoundedAnimation<V>
- An animation with a known duration
Combinators
Celerity has a set of animation combinators which can be used to produce higher-order animations:
Chain<A, B, V>
- Play animation A, then play animation BCutoff<A, V>
- Play only part of animation ACycle<A, V>
- Repeat animation A indefinitelyInterrupt<B, V>
- Interrupt an animation A in the middle and transition into a smooth animation BRev<A, V>
- Reverse a bounded animation
Keyframes vs Intervals
In the API, there are two ways to specify track animations:
- A user-friendly
Keyframe
API - A code-friendly
Interval
API.
In the first, an animation Track
contains Keyframe
s with values at specific points in time. This representation is easiest to define and edit, with a single source of truth for each value.
In the second, an animation contains Interval
s, each of which is a self-contained data structure. This representation is optimized for playback. It describes the entire animation between time t1
and t2
, with no dependency on the interval before or after.