Add `Color32::mul` (#5437)
Multiply two `Color32` together quickly, in gamma-space
This commit is contained in:
parent
291b83b7be
commit
046034f902
|
|
@ -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),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ impl<'a> Button<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
/// If true, the tint of the image is the same as the text color.
|
||||
/// If true, the tint of the image is multiplied by the widget text color.
|
||||
///
|
||||
/// This makes sense for images that are white, that should have the same color as the text color.
|
||||
/// This will also make the icon color depend on hover state.
|
||||
|
|
@ -336,7 +336,7 @@ impl Widget for Button<'_> {
|
|||
let tlr = image.load_for_size(ui.ctx(), image_size);
|
||||
let mut image_options = image.image_options().clone();
|
||||
if image_tint_follows_text_color {
|
||||
image_options.tint = visuals.text_color();
|
||||
image_options.tint = image_options.tint * visuals.text_color();
|
||||
}
|
||||
widgets::image::paint_texture_load_result(
|
||||
ui,
|
||||
|
|
|
|||
Loading…
Reference in New Issue