Add Color::lerp()

This commit is contained in:
mars 2022-11-05 14:25:59 -06:00
parent 4798d43f6c
commit 681b884b74
1 changed files with 6 additions and 0 deletions

View File

@ -168,6 +168,12 @@ impl Color {
pub fn with_alpha(&self, alpha: u8) -> Self {
Self(self.0 & 0xffffff00 | alpha as u32)
}
pub fn lerp(self, target: Self, blend: f32) -> Self {
let s: glam::Vec4 = self.into();
let o: glam::Vec4 = target.into();
(o * blend + s * (1.0 - blend)).into()
}
}
#[repr(C)]