pub enum EasingCurve {
CubicBezier(f32, f32, f32, f32),
Spring {
stiffness: f32,
damping: f32,
},
}Expand description
Declarative easing curve with only two variants.
Standard curves (linear, ease-in, ease-out, ease-in-out) are cubic bezier curves with predefined control points. Custom bezier curves can be created with any control points.
Spring animations cannot be represented by bezier curves due to their oscillating nature, so they have a separate variant.
Variants§
CubicBezier(f32, f32, f32, f32)
Cubic bezier curve with control points (x1, y1, x2, y2).
The curve starts at (0, 0) and ends at (1, 1). The control points define the shape of the curve between these endpoints.
Standard CSS bezier curves are provided as constants.
Spring
Spring physics animation.
Spring animations cannot be represented by bezier curves because they can overshoot the target value and oscillate before settling.
Implementations§
Source§impl EasingCurve
impl EasingCurve
Sourcepub const LINEAR: Self
pub const LINEAR: Self
Linear interpolation - constant velocity from start to finish.
CSS: linear or cubic-bezier(0, 0, 1, 1)
Sourcepub const EASE_IN: Self
pub const EASE_IN: Self
Ease-in - starts slow and accelerates.
CSS: ease-in or cubic-bezier(0.42, 0, 1, 1)
Sourcepub const EASE_OUT: Self
pub const EASE_OUT: Self
Ease-out - starts fast and decelerates.
CSS: ease-out or cubic-bezier(0, 0, 0.58, 1)
Sourcepub const EASE_IN_OUT: Self
pub const EASE_IN_OUT: Self
Ease-in-out - starts slow, speeds up, then slows down.
CSS: ease-in-out or cubic-bezier(0.42, 0, 0.58, 1)
Sourcepub const EASE: Self
pub const EASE: Self
Default ease curve (CSS ease).
CSS: ease or cubic-bezier(0.25, 0.1, 0.25, 1)
Sourcepub const fn bezier(x1: f32, y1: f32, x2: f32, y2: f32) -> Self
pub const fn bezier(x1: f32, y1: f32, x2: f32, y2: f32) -> Self
Creates a custom cubic bezier curve.
Sourcepub const fn spring(stiffness: f32, damping: f32) -> Self
pub const fn spring(stiffness: f32, damping: f32) -> Self
Creates a spring animation with the given stiffness and damping.
Trait Implementations§
Source§impl Clone for EasingCurve
impl Clone for EasingCurve
Source§fn clone(&self) -> EasingCurve
fn clone(&self) -> EasingCurve
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more