Skip to main content

Easing

Enum Easing 

Source
pub enum Easing {
Show 31 variants Linear, InQuad, OutQuad, InOutQuad, InCubic, OutCubic, InOutCubic, InQuart, OutQuart, InOutQuart, InQuint, OutQuint, InOutQuint, InSine, OutSine, InOutSine, InExpo, OutExpo, InOutExpo, InCirc, OutCirc, InOutCirc, InBack, OutBack, InOutBack, InElastic, OutElastic, InOutElastic, InBounce, OutBounce, InOutBounce,
}
Expand description

The complete set of Robert Penner easing functions used to warp a linear interpolation parameter into an accelerated / decelerated curve.

Each variant maps a normalized input t in the range 0.0 to 1.0 to an eased output, following the same naming as mainstream engines (Godot Tween::EaseType, Phaser Ease, CSS timing-function).

Variants§

§

Linear

Constant velocity: f(t) = t.

§

InQuad

Quadratic acceleration from zero velocity.

§

OutQuad

Quadratic deceleration to zero velocity.

§

InOutQuad

Quadratic acceleration until halfway, then deceleration.

§

InCubic

Cubic acceleration from zero velocity.

§

OutCubic

Cubic deceleration to zero velocity.

§

InOutCubic

Cubic acceleration until halfway, then deceleration.

§

InQuart

Quartic acceleration from zero velocity.

§

OutQuart

Quartic deceleration to zero velocity.

§

InOutQuart

Quartic acceleration until halfway, then deceleration.

§

InQuint

Quintic acceleration from zero velocity.

§

OutQuint

Quintic deceleration to zero velocity.

§

InOutQuint

Quintic acceleration until halfway, then deceleration.

§

InSine

Sinusoidal acceleration from zero velocity.

§

OutSine

Sinusoidal deceleration to zero velocity.

§

InOutSine

Sinusoidal acceleration until halfway, then deceleration.

§

InExpo

Exponential acceleration from zero velocity.

§

OutExpo

Exponential deceleration to zero velocity.

§

InOutExpo

Exponential acceleration until halfway, then deceleration.

§

InCirc

Circular acceleration from zero velocity.

§

OutCirc

Circular deceleration to zero velocity.

§

InOutCirc

Circular acceleration until halfway, then deceleration.

§

InBack

Overshoots backwards before moving forwards.

§

OutBack

Overshoots the target then settles back onto it.

§

InOutBack

Overshoots backwards then forwards past the target before settling.

§

InElastic

Elastic oscillation building up from rest.

§

OutElastic

Elastic oscillation settling down onto the target.

§

InOutElastic

Elastic oscillation at both ends.

§

InBounce

Bounces off the start before moving forwards.

§

OutBounce

Bounces off the target like a dropped ball.

§

InOutBounce

Bounces at both ends.

Implementations§

Source§

impl Easing

Implements easing curve evaluation for Easing.

Source

pub fn evaluate(&self, t: f64) -> f64

Evaluates the easing curve at the given normalized time.

The input is clamped into the range 0.0 to 1.0 before evaluation, so callers may pass slightly out-of-range accumulators without producing out-of-range output.

§Arguments
  • f64 - The normalized time, typically in the range 0.0 to 1.0.
§Returns
  • f64 - The eased value, where 0.0 maps to the start and 1.0 to the end.
Source

pub fn interpolate(&self, start: f64, end: f64, t: f64) -> f64

Applies this easing curve to interpolate between two scalar values.

§Arguments
  • f64 - The start value.
  • f64 - The end value.
  • f64 - The normalized time, typically in the range 0.0 to 1.0.
§Returns
  • f64 - The eased interpolation between start and end.

Trait Implementations§

Source§

impl Clone for Easing

Source§

fn clone(&self) -> Easing

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 Easing

Source§

impl Debug for Easing

Source§

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

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

impl Default for Easing

Source§

fn default() -> Easing

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

impl Eq for Easing

Source§

impl PartialEq for Easing

Source§

fn eq(&self, other: &Easing) -> 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 Easing

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, 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 = Infallible

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more