pub enum Easing {
Show 34 variants
Linear,
EaseInQuad,
EaseOutQuad,
EaseInOutQuad,
EaseInCubic,
EaseOutCubic,
EaseInOutCubic,
EaseInQuart,
EaseOutQuart,
EaseInOutQuart,
EaseInQuint,
EaseOutQuint,
EaseInOutQuint,
EaseInSine,
EaseOutSine,
EaseInOutSine,
EaseInExpo,
EaseOutExpo,
EaseInOutExpo,
EaseInCirc,
EaseOutCirc,
EaseInOutCirc,
EaseInBack,
EaseOutBack,
EaseInOutBack,
EaseInElastic,
EaseOutElastic,
EaseInOutElastic,
EaseInBounce,
EaseOutBounce,
EaseInOutBounce,
CubicBezier(f32, f32, f32, f32),
Steps(u32),
Custom(fn(f32) -> f32),
}Expand description
All 31 classic easing variants, CSS-compatible parameterized variants,
and an escape-hatch Custom function pointer.
§PartialEq behaviour
Custom(_) never equals anything (including itself) because function
pointers aren’t meaningfully comparable by identity in this context.
All other variants use structural equality, including parameter values for
CubicBezier and Steps.
§Serialization
With the serde feature, all variants except Custom are serializable.
Custom is skipped — function pointers cannot be serialized.
Variants§
Linear
Constant velocity — no acceleration.
EaseInQuad
Quadratic ease-in (accelerates from zero velocity).
EaseOutQuad
Quadratic ease-out (decelerates to zero velocity).
EaseInOutQuad
Quadratic ease-in-out (accelerates then decelerates).
EaseInCubic
Cubic ease-in.
EaseOutCubic
Cubic ease-out.
EaseInOutCubic
Cubic ease-in-out.
EaseInQuart
Quartic ease-in.
EaseOutQuart
Quartic ease-out.
EaseInOutQuart
Quartic ease-in-out.
EaseInQuint
Quintic ease-in.
EaseOutQuint
Quintic ease-out.
EaseInOutQuint
Quintic ease-in-out.
EaseInSine
Sinusoidal ease-in.
EaseOutSine
Sinusoidal ease-out.
EaseInOutSine
Sinusoidal ease-in-out.
EaseInExpo
Exponential ease-in.
EaseOutExpo
Exponential ease-out.
EaseInOutExpo
Exponential ease-in-out.
EaseInCirc
Circular ease-in.
EaseOutCirc
Circular ease-out.
EaseInOutCirc
Circular ease-in-out.
EaseInBack
Back ease-in — slight overshoot at the start.
EaseOutBack
Back ease-out — slight overshoot at the end.
EaseInOutBack
Back ease-in-out.
EaseInElastic
Elastic ease-in — spring-like oscillation at the start.
EaseOutElastic
Elastic ease-out — spring-like oscillation at the end.
EaseInOutElastic
Elastic ease-in-out.
EaseInBounce
Bounce ease-in — ball bounce at the start.
EaseOutBounce
Bounce ease-out — ball bounces to rest at the end.
EaseInOutBounce
Bounce ease-in-out.
CubicBezier(f32, f32, f32, f32)
CSS-compatible cubic Bezier easing: (x1, y1, x2, y2).
The x control points are clamped to [0.0, 1.0] before evaluation,
matching the valid CSS timing-function domain. The y control points may
overshoot to support anticipation and bounce-like curves.
Steps(u32)
CSS steps(n, jump-end) easing.
0 is treated as 1 step so invalid input remains safe.
Custom(fn(f32) -> f32)
Custom function pointer — zero overhead, no allocation.
Not serializable and does not participate in PartialEq (always false).
use animato_core::Easing;
let e = Easing::Custom(|t| t * t * t);
assert_eq!(e.apply(0.5), 0.125);Implementations§
Source§impl Easing
impl Easing
Sourcepub fn apply(&self, t: f32) -> f32
pub fn apply(&self, t: f32) -> f32
Evaluate the easing function at t.
t is clamped to [0.0, 1.0] before evaluation — out-of-range
values never panic and never extrapolate for named variants.
§Example
use animato_core::Easing;
assert_eq!(Easing::Linear.apply(0.5), 0.5);
assert_eq!(Easing::EaseInQuad.apply(0.0), 0.0);
assert_eq!(Easing::EaseInQuad.apply(1.0), 1.0);
// Out-of-range — no panic:
let _ = Easing::EaseOutCubic.apply(-1.0);
let _ = Easing::EaseOutCubic.apply(2.0);