Skip to main content

Lerp

Trait Lerp 

Source
pub trait Lerp: Copy {
    // Required method
    fn mix(from: Self, to: Self, p: i32) -> Self;
}
Expand description

A type that goes between two of its values.

mix(from, to, p) is from + (to - from) * p / ONE, rounded to the nearest with halves up: exactly from at 0 and exactly to at ONE. Past them (an overshoot) it goes on in a line, and stops at the type’s bounds: a u8, a colour’s channel, stops at 0 and 255.

It is not called lerp, because shuyi_ui’s Rgb has an inherent lerp in f32.

Required Methods§

Source

fn mix(from: Self, to: Self, p: i32) -> Self

The value p (in 1/65536) of the way from from to to.

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 (i32, i32)

Source§

fn mix(from: Self, to: Self, p: i32) -> Self

Source§

impl Lerp for i32

Source§

fn mix(from: Self, to: Self, p: i32) -> Self

Source§

impl Lerp for i64

Source§

fn mix(from: Self, to: Self, p: i32) -> Self

Source§

impl Lerp for u8

Source§

fn mix(from: Self, to: Self, p: i32) -> Self

Source§

impl Lerp for u16

Source§

fn mix(from: Self, to: Self, p: i32) -> Self

Source§

impl Lerp for u32

Source§

fn mix(from: Self, to: Self, p: i32) -> Self

Implementors§