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:
@@ -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),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user