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]BackOut
Overshoots the target before settling; built by Easing::back_out.
Fields
This variant is marked as non-exhaustive
#[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]ElasticOut
Exponentially damped oscillation, pinned at both endpoints; built by Easing::elastic_out.
Fields
This variant is marked as non-exhaustive
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
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
impl Easing
Sourcepub fn back_in(overshoot: f64) -> Result<Self, ValidationError>
pub fn back_in(overshoot: f64) -> Result<Self, ValidationError>
Builds Self::BackIn, rejecting a nonfinite or negative overshoot.
Sourcepub fn back_out(overshoot: f64) -> Result<Self, ValidationError>
pub fn back_out(overshoot: f64) -> Result<Self, ValidationError>
Builds Self::BackOut, rejecting a nonfinite or negative overshoot.
Sourcepub fn back_in_out(overshoot: f64) -> Result<Self, ValidationError>
pub fn back_in_out(overshoot: f64) -> Result<Self, ValidationError>
Builds Self::BackInOut, rejecting a nonfinite or negative overshoot.
Sourcepub fn elastic_out(amplitude: f64, period: f64) -> Result<Self, ValidationError>
pub fn elastic_out(amplitude: f64, period: f64) -> Result<Self, ValidationError>
Builds Self::ElasticOut, rejecting an amplitude below one or a nonpositive period.
Sourcepub fn steps(count: u32) -> Result<Self, ValidationError>
pub fn steps(count: u32) -> Result<Self, ValidationError>
Builds Self::Steps, rejecting a zero count.
Sourcepub fn cubic_bezier(
x1: f64,
y1: f64,
x2: f64,
y2: f64,
) -> Result<Self, ValidationError>
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.
Sourcepub fn apply(&self, progress: f64) -> f64
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.
Sourcepub fn try_apply(&self, progress: f64) -> Result<f64, ValidationError>
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.