Skip to main content

Easing

Enum Easing 

Source
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

Source

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);
Source

pub fn all_named() -> &'static [Easing]

Returns a slice of all named (non-Custom) variants.

Useful for picker UIs and exhaustive test sweeps.

use animato_core::Easing;
for e in Easing::all_named() {
    assert_eq!(e.apply(0.0), 0.0);
    assert_eq!(e.apply(1.0), 1.0);
}

Trait Implementations§

Source§

impl Clone for Easing

Source§

fn clone(&self) -> Easing

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Easing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Easing

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.