Skip to main content

EasingCurve

Enum EasingCurve 

Source
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.

Fields

§stiffness: f32

Stiffness of the spring (higher = faster oscillation).

§damping: f32

Damping factor (higher = less bounce/oscillation).

Implementations§

Source§

impl EasingCurve

Source

pub const LINEAR: Self

Linear interpolation - constant velocity from start to finish. CSS: linear or cubic-bezier(0, 0, 1, 1)

Source

pub const EASE_IN: Self

Ease-in - starts slow and accelerates. CSS: ease-in or cubic-bezier(0.42, 0, 1, 1)

Source

pub const EASE_OUT: Self

Ease-out - starts fast and decelerates. CSS: ease-out or cubic-bezier(0, 0, 0.58, 1)

Source

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)

Source

pub const EASE: Self

Default ease curve (CSS ease). CSS: ease or cubic-bezier(0.25, 0.1, 0.25, 1)

Source

pub const fn bezier(x1: f32, y1: f32, x2: f32, y2: f32) -> Self

Creates a custom cubic bezier curve.

Source

pub const fn spring(stiffness: f32, damping: f32) -> Self

Creates a spring animation with the given stiffness and damping.

Source

pub fn ease(&self, t: f32) -> f32

Apply easing to a normalized time value t in [0, 1].

Returns the eased progress value, which for most curves is also in [0, 1], but spring animations may temporarily overshoot (return values > 1 or < 0).

Source

pub const fn is_spring(&self) -> bool

Returns true if this is a spring animation.

Trait Implementations§

Source§

impl Clone for EasingCurve

Source§

fn clone(&self) -> EasingCurve

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 Copy for EasingCurve

Source§

impl Debug for EasingCurve

Source§

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

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

impl Default for EasingCurve

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for EasingCurve

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EasingCurve

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> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
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, <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.