2020-05-07 08:47:03 +00:00
|
|
|
/// 0-255 `sRGBA`. TODO: rename `sRGBA` for clarity.
|
|
|
|
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd, serde_derive::Serialize)]
|
2019-04-25 16:07:36 +00:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 20:59:49 +00:00
|
|
|
pub const BLACK: Color = srgba(0, 0, 0, 255);
|
2020-04-24 16:32:27 +00:00
|
|
|
pub const LIGHT_GRAY: Color = srgba(220, 220, 220, 255);
|
|
|
|
pub const WHITE: Color = srgba(255, 255, 255, 255);
|
2019-12-02 20:59:49 +00:00
|
|
|
pub const RED: Color = srgba(255, 0, 0, 255);
|
|
|
|
pub const GREEN: Color = srgba(0, 255, 0, 255);
|
|
|
|
pub const BLUE: Color = srgba(0, 0, 255, 255);
|
2020-04-25 12:37:39 +00:00
|
|
|
pub const YELLOW: Color = srgba(255, 255, 0, 255);
|
2020-04-23 17:15:17 +00:00
|
|
|
pub const LIGHT_BLUE: Color = srgba(140, 160, 255, 255);
|