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

Better handle additive colors in plots (#3387)

This commit is contained in:
Emil Ernerfeldt
2023-09-25 15:45:32 +02:00
committed by GitHub
parent fdd493d48f
commit 8bf0055bda
3 changed files with 23 additions and 3 deletions

View File

@@ -155,6 +155,12 @@ impl Color32 {
Self([r, g, b, 0])
}
/// Is the alpha=0 ?
#[inline(always)]
pub fn is_additive(self) -> bool {
self.a() == 0
}
/// Premultiplied RGBA
#[inline(always)]
pub const fn to_array(&self) -> [u8; 4] {

View File

@@ -122,6 +122,12 @@ impl Rgba {
Self([r, g, b, 0.0])
}
/// Is the alpha=0 ?
#[inline(always)]
pub fn is_additive(self) -> bool {
self.a() == 0.0
}
/// Multiply with e.g. 0.5 to make us half transparent
#[inline(always)]
pub fn multiply(self, alpha: f32) -> Self {