pub enum Easing {
Show 24 variants
Linear,
SineIn,
SineOut,
SineInOut,
QuadraticIn,
QuadraticOut,
QuadraticInOut,
CubicIn,
CubicOut,
CubicInOut,
QuarticIn,
QuarticOut,
QuarticInOut,
ExponentialIn,
ExponentialOut,
ExponentialInOut,
BackIn {
overshoot: f64,
},
BackOut {
overshoot: f64,
},
BackInOut {
overshoot: f64,
},
ElasticOut {
amplitude: f64,
period: f64,
},
BounceOut,
Steps(u32),
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. Parameters are checked when sampled; invalid parameters, nonfinite progress and nonfinite custom output panic rather than being hidden.
use motion_core::prelude::*;
use motion_core::{
DisplayList, RasterLimits, ResourcePool, 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()), 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.
BackIn
Initial backward movement before acceleration.
BackOut
Overshoots the target before settling.
BackInOut
Mirrored BackIn, using the coefficient directly without an extra multiplier.
ElasticOut
Exponentially damped oscillation, pinned at both endpoints.
Fields
BounceOut
A piecewise quadratic outward bounce.
Steps(u32)
Right-continuous equal steps; the count must be nonzero.
CubicBezier
Unit-endpoint cubic Bezier, solving X before evaluating Y.
Fields
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 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.
§Panics
Panics for invalid curve parameters, nonfinite progress or nonfinite output.
Sourcepub fn try_apply(&self, progress: f64) -> Result<f64, ValidationError>
pub fn try_apply(&self, progress: f64) -> Result<f64, ValidationError>
Evaluates progress with recoverable parameter/output diagnostics. Panics raised inside a user callback still propagate unchanged.
Sourcepub fn reversed(self) -> Self
pub fn reversed(self) -> Self
Converts an inward curve to its outward counterpart: 1 - f(1 - t).
Invalid built-in parameters panic before the wrapper is constructed.
Sourcepub fn mirrored(self) -> Self
pub fn mirrored(self) -> Self
Uses the curve for acceleration and its reversal for deceleration. Invalid built-in parameters panic before the wrapper is constructed.
Sourcepub fn try_validate(&self) -> Result<(), ValidationError>
pub fn try_validate(&self) -> Result<(), ValidationError>
Checks built-in parameters without evaluating a custom callback.