update delta diff

This commit is contained in:
Andre Henriques 2023-03-15 22:52:45 +00:00
parent 540af20174
commit 16ea28557e

View File

@ -333,28 +333,13 @@ pub trait Lerp {
fn lerp(self, other: &Self, diff: f64) -> Self;
}
impl Lerp for u8 {
fn lerp(self, other: &Self, diff: f64) -> Self {
let delta = diff / 1_000_000.0;
((self as f64) + (((*other as f64) - (self as f64)) * 0.5 * delta)) as u8
}
}
impl Lerp for f64 {
fn lerp(self, other: &Self, diff: f64) -> Self {
let delta = diff / 1000.0;
let delta = diff / 1_000_000.0;
self + ((*other - self) * 0.5 * delta)
}
}
impl Lerp for RGB<u8> {
fn lerp(self, other: &Self, diff: f64) -> Self {
RGB::new(self.r.lerp(&other.r, diff), self.g.lerp(&other.g, diff), self.b.lerp(&other.b, diff))
}
}
impl Lerp for RGB<f64> {
fn lerp(self, other: &Self, diff: f64) -> Self {
RGB::new(self.r.lerp(&other.r, diff), self.g.lerp(&other.g, diff), self.b.lerp(&other.b, diff))