1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Add Color32::mul (#5437)

Multiply two `Color32` together quickly, in gamma-space
This commit is contained in:
Emil Ernerfeldt
2024-12-05 13:53:20 +01:00
committed by GitHub
parent 291b83b7be
commit 046034f902
2 changed files with 17 additions and 2 deletions

View File

@@ -269,3 +269,18 @@ impl Color32 {
)
}
}
impl std::ops::Mul for Color32 {
type Output = Self;
/// Fast gamma-space multiplication.
#[inline]
fn mul(self, other: Self) -> Self {
Self([
fast_round(self[0] as f32 * other[0] as f32 / 255.0),
fast_round(self[1] as f32 * other[1] as f32 / 255.0),
fast_round(self[2] as f32 * other[2] as f32 / 255.0),
fast_round(self[3] as f32 * other[3] as f32 / 255.0),
])
}
}