Skip to main content

Tweenable

Trait Tweenable 

Source
pub trait Tweenable: Sized {
    // Required method
    fn lerp(self, other: Self, t: f32) -> Self;

    // Provided method
    fn tween(self, other: Self, t: f32, easing: EasingFn) -> Self { ... }
}
Expand description

A type that can be interpolated between two values.

The default tween method applies an easing function to the parameter t before delegating to lerp.

Required Methods§

Source

fn lerp(self, other: Self, t: f32) -> Self

Linearly interpolates between self and other.

When t = 0.0, returns self. When t = 1.0, returns other.

Provided Methods§

Source

fn tween(self, other: Self, t: f32, easing: EasingFn) -> Self

Interpolates between self and other using an easing function.

The easing function is applied to t before interpolation, producing non-linear motion curves.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Tweenable for f32

Source§

fn lerp(self, other: Self, t: f32) -> Self

Implementors§