Skip to main content

wtk/
pixels.rs

1#[derive(Debug, Clone, Copy)]
2pub struct Color {
3    pub r: u8,
4    pub g: u8,
5    pub b: u8,
6    pub a: u8,
7}
8
9impl Into<Color> for (u8,u8,u8,u8) {
10    fn into(self) -> Color {
11        Color { r: self.0, g: self.1, b: self.2, a: self.3 }
12    }
13}
14
15impl Color {
16    pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
17        Color { r, g, b, a: 255}
18    }
19    pub const BLACK: Color = Color::rgb(0, 0, 0);
20    pub const WHITE: Color = Color::rgb(0xff, 0xff, 0xff);
21}