Skip to main content

Easing

Enum Easing 

Source
pub enum Easing {
Show 24 variants Linear, SineIn, SineOut, SineInOut, QuadraticIn, QuadraticOut, QuadraticInOut, CubicIn, CubicOut, CubicInOut, QuarticIn, QuarticOut, QuarticInOut, ExponentialIn, ExponentialOut, ExponentialInOut,
#[non_exhaustive]
BackIn { overshoot: f64, },
#[non_exhaustive]
BackOut { overshoot: f64, },
#[non_exhaustive]
BackInOut { overshoot: f64, },
#[non_exhaustive]
ElasticOut { amplitude: f64, period: f64, }, BounceOut,
#[non_exhaustive]
Steps(u32),
#[non_exhaustive]
CubicBezier { x1: f64, y1: f64, x2: f64, y2: f64, }, Custom(Arc<dyn Fn(f64) -> f64 + Send + Sync>),
}
Expand description

A normalized double-precision easing curve, independent of clip duration.

Finite input is clamped to the unit interval with exact zero/one endpoints. Output may overshoot. Parameterized curves are built with the validated constructors such as Self::back_in and Self::cubic_bezier, so sampling never rechecks parameters; Self::try_apply reports nonfinite progress and output.

use motion_core::prelude::*;
use motion_core::{
    DisplayList, RasterLimits, ResourceStore, ValidatedDisplayList, MAX_PATH_VERBS,
    MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
let movement = Tween::new(0.0_f64, 100.0, 2.seconds()).easing(Easing::CubicOut);
assert_eq!(movement.sample(1.seconds().after_origin()), 87.5);

Variants§

§

Linear

Constant speed.

§

SineIn

Sinusoidal acceleration.

§

SineOut

Sinusoidal deceleration.

§

SineInOut

Symmetric sinusoidal movement.

§

QuadraticIn

Quadratic acceleration.

§

QuadraticOut

Quadratic deceleration.

§

QuadraticInOut

Symmetric quadratic movement.

§

CubicIn

Cubic acceleration.

§

CubicOut

Cubic deceleration.

§

CubicInOut

Symmetric cubic movement.

§

QuarticIn

Quartic acceleration.

§

QuarticOut

Quartic deceleration.

§

QuarticInOut

Symmetric quartic movement.

§

ExponentialIn

Base-two exponential acceleration, pinned at zero.

§

ExponentialOut

Base-two exponential deceleration, pinned at one.

§

ExponentialInOut

Symmetric exponential movement.

§

#[non_exhaustive]
BackIn

Initial backward movement before acceleration; built by Easing::back_in.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§overshoot: f64

Finite, nonnegative backward coefficient.

§

#[non_exhaustive]
BackOut

Overshoots the target before settling; built by Easing::back_out.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§overshoot: f64

Finite, nonnegative overshoot coefficient.

§

#[non_exhaustive]
BackInOut

Mirrored BackIn, using the coefficient directly without an extra multiplier; built by Easing::back_in_out.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§overshoot: f64

Finite, nonnegative coefficient for each half.

§

#[non_exhaustive]
ElasticOut

Exponentially damped oscillation, pinned at both endpoints; built by Easing::elastic_out.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§amplitude: f64

Finite amplitude, at least one.

§period: f64

Finite, strictly positive period in normalized time.

§

BounceOut

A piecewise quadratic outward bounce.

§

#[non_exhaustive]
Steps(u32)

Right-continuous equal steps; built by Easing::steps, which requires a nonzero count.

§

#[non_exhaustive]
CubicBezier

Unit-endpoint cubic Bezier, solving X before evaluating Y; built by Easing::cubic_bezier.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§x1: f64

First X control, finite and in 0..=1.

§y1: f64

First Y control, finite and allowed to overshoot.

§x2: f64

Second X control, finite and in 0..=1.

§y2: f64

Second Y control, finite and allowed to overshoot.

§

Custom(Arc<dyn Fn(f64) -> f64 + Send + Sync>)

A deterministic, thread-safe mapping with finite output. Input is clamped to 0..=1; callback endpoint values are preserved.

Implementations§

Source§

impl Easing

Source

pub fn back_in(overshoot: f64) -> Result<Self, ValidationError>

Builds Self::BackIn, rejecting a nonfinite or negative overshoot.

Source

pub fn back_out(overshoot: f64) -> Result<Self, ValidationError>

Builds Self::BackOut, rejecting a nonfinite or negative overshoot.

Source

pub fn back_in_out(overshoot: f64) -> Result<Self, ValidationError>

Builds Self::BackInOut, rejecting a nonfinite or negative overshoot.

Source

pub fn elastic_out(amplitude: f64, period: f64) -> Result<Self, ValidationError>

Builds Self::ElasticOut, rejecting an amplitude below one or a nonpositive period.

Source

pub fn steps(count: u32) -> Result<Self, ValidationError>

Builds Self::Steps, rejecting a zero count.

Source

pub fn cubic_bezier( x1: f64, y1: f64, x2: f64, y2: f64, ) -> Result<Self, ValidationError>

Builds Self::CubicBezier, rejecting nonfinite controls and X controls outside 0..=1.

Source

pub fn apply(&self, progress: f64) -> f64

Evaluates normalized progress with double-precision math. Built-in transcendental operations use libm, not platform math routines.

Infinite progress clamps to the endpoints and NaN produces NaN; a custom callback’s output is returned as given. Use Self::try_apply to reject nonfinite values.

Source

pub fn try_apply(&self, progress: f64) -> Result<f64, ValidationError>

Evaluates progress, reporting nonfinite progress or output. Panics raised inside a user callback still propagate unchanged.

Source

pub fn reversed(self) -> Self

Converts an inward curve to its outward counterpart: 1 - f(1 - t).

Source

pub fn mirrored(self) -> Self

Uses the curve for acceleration and its reversal for deceleration.

Trait Implementations§

Source§

impl Clone for Easing

Source§

fn clone(&self) -> Self

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, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Easing

§

impl !UnwindSafe for Easing

§

impl Forget for Easing

§

impl Freeze for Easing

§

impl Move for Easing

§

impl Send for Easing

§

impl Sync for Easing

§

impl Unpin for Easing

§

impl UnsafeUnpin for Easing

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.