egui/emigui/src/color.rs

35 lines
610 B
Rust
Raw Normal View History

2019-04-25 16:07:36 +00:00
/// 0-255 sRGBA
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl Color {
pub fn transparent(self) -> Color {
Color {
r: self.r,
g: self.g,
b: self.b,
a: 0,
}
}
}
pub const fn srgba(r: u8, g: u8, b: u8, a: u8) -> Color {
Color { r, g, b, a }
}
pub const fn gray(l: u8, a: u8) -> Color {
Color {
r: l,
g: l,
b: l,
a,
}
}
pub const WHITE: Color = srgba(255, 255, 255, 255);