pub trait Interpolate: Sized {
// Required method
fn lerp(&self, other: &Self, t: f32) -> Self;
}Expand description
A value that supports linear interpolation between two instances.
Implement this trait for any type you want to animate with Animato.
The library ships blanket impls for f32, f64, [f32; 2],
[f32; 3], [f32; 4], i32, and u8.
§Contract
self.lerp(other, 0.0)must equal*selfself.lerp(other, 1.0)must equal*othertoutside[0.0, 1.0]is allowed — implementations may extrapolate or clamp
§Example
use animato_core::Interpolate;
let a = 0.0_f32;
let b = 100.0_f32;
assert_eq!(a.lerp(&b, 0.0), 0.0);
assert_eq!(a.lerp(&b, 1.0), 100.0);
assert_eq!(a.lerp(&b, 0.5), 50.0);Required Methods§
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.