Animatable

Trait Animatable 

Source
pub trait Animatable:
    Copy
    + 'static
    + Default
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<f32, Output = Self> {
    // Required methods
    fn interpolate(&self, target: &Self, t: f32) -> Self;
    fn magnitude(&self) -> f32;

    // Provided method
    fn epsilon() -> f32 { ... }
}
Expand description

A simplified trait for types that can be animated

This trait leverages standard Rust operator traits for mathematical operations, reducing boilerplate and making implementations more intuitive. Only requires implementing interpolation and magnitude calculation.

Required Methods§

Source

fn interpolate(&self, target: &Self, t: f32) -> Self

Interpolates between self and target using t (0.0 to 1.0)

Source

fn magnitude(&self) -> f32

Calculates the magnitude/distance from zero Used for determining animation completion

Provided Methods§

Source

fn epsilon() -> f32

Returns the epsilon threshold for this type Default implementation provides a reasonable value for most use cases

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 Animatable for f32

Implementation of Animatable for f32 primitive type Much simpler with the new trait design - leverages standard Rust operators

Source§

fn interpolate(&self, target: &Self, t: f32) -> Self

Source§

fn magnitude(&self) -> f32

Implementors§

Source§

impl Animatable for Color

Implementation of Animatable for Color Much simpler with the new trait design - uses standard operators

Source§

impl Animatable for Transform

Implementation of Animatable for Transform Much simpler with the new trait design - uses standard operators