Trait mina::EasingFunction

source ·
pub trait EasingFunction: Debug + DynClone + Send + Sync {
    // Required method
    fn calc(&self, x: f32) -> f32;
}
Expand description

Provides an easing function, AKA animation timing function, for non-linear interpolation of values, typically along some curve.

Easing functions and Lerp are complementary. Lerp is always responsible for determining the value of a given animation property at a given time t (or x in lerp terminology), but EasingFunction can modify which x value the lerp will use in its evaluation. This has the same effect as using the easing function directly, because linear interpolation constitutes an identity function over normalized y.

Required Methods§

source

fn calc(&self, x: f32) -> f32

Computes the y value along the curve for a given x position.

Expects x to be normalized (from 0 to 1) and returns a normalized y-value which is typically between 0 and 1, but may be outside that range (e.g. Easing::OutBack).

Implementors§