Skip to main content

Lerp

Trait Lerp 

Source
pub trait Lerp: Clone {
    // Required method
    fn lerp(&self, to: &Self, t: f64) -> Self;
}
Expand description

A value that can be interpolated: a.lerp(&b, 0.0) is a, a.lerp(&b, 1.0) is b.

t may leave 0..=1: an under-damped spring overshoots, and a numeric value follows it past the target and back. Implementations that cannot extrapolate (a color’s alpha, a count) clamp the parts that must stay in range.

Required Methods§

Source

fn lerp(&self, to: &Self, t: f64) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Lerp for Color

Colors blend in OKLab (Björn Ottosson’s perceptual space), alpha linearly: the midpoint of blue and yellow is a clean mid-lightness color rather than sRGB’s dim gray, and a sequential scale’s in-between cells read as in-between values. The endpoints are exact.

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl Lerp for Point

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl Lerp for Rect

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl Lerp for Size

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl Lerp for f32

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl Lerp for f64

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl<A: Lerp, B: Lerp, C: Lerp> Lerp for (A, B, C)

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl<A: Lerp, B: Lerp> Lerp for (A, B)

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl<T: Lerp, const N: usize> Lerp for [T; N]

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl<T: Lerp> Lerp for Option<T>

Both present: interpolate. Otherwise there is nothing to move between, so the value switches at the midpoint.

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Source§

impl<T: Lerp> Lerp for Vec<T>

Element-wise over the common prefix; the target’s extra elements (or the source’s missing ones) take the target’s values, so a series that grew draws its new tail where it is headed. A caller that wants entering elements to grow in matches them up first; Vec has no idea what they mean.

Source§

fn lerp(&self, to: &Self, t: f64) -> Self

Implementors§

Day API ↩ Guides· daybrite.dev