1#[derive(Clone, Copy, Debug)]
5pub struct Color {
6 pub r: f64,
7 pub g: f64,
8 pub b: f64,
9 pub a: f64,
10}
11
12impl Color {
13 pub const fn new(r: f64, g: f64, b: f64, a: f64) -> Self {
14 Self { r, g, b, a }
15 }
16
17 pub const fn rgb(r: f64, g: f64, b: f64) -> Self {
18 Self { r, g, b, a: 1.0 }
19 }
20
21 pub fn hex(hex: u32) -> Self {
22 Self {
23 r: ((hex >> 16) & 0xFF) as f64 / 255.0,
24 g: ((hex >> 8) & 0xFF) as f64 / 255.0,
25 b: (hex & 0xFF) as f64 / 255.0,
26 a: 1.0,
27 }
28 }
29
30 pub const RED: Self = Self::new(1.0, 0.0, 0.0, 1.0);
31 pub const GREEN: Self = Self::new(0.0, 1.0, 0.0, 1.0);
32 pub const BLUE: Self = Self::new(0.0, 0.0, 1.0, 1.0);
33 pub const WHITE: Self = Self::new(1.0, 1.0, 1.0, 1.0);
34 pub const BLACK: Self = Self::new(0.0, 0.0, 0.0, 1.0);
35 pub const CLEAR: Self = Self::new(0.0, 0.0, 0.0, 0.0);
36 pub const GRAY: Self = Self::new(0.5, 0.5, 0.5, 1.0);
37 pub const YELLOW: Self = Self::new(1.0, 1.0, 0.0, 1.0);
38 pub const PURPLE: Self = Self::new(0.5, 0.0, 0.5, 1.0);
39 pub const DARK: Self = Self::new(0.15, 0.15, 0.15, 1.0);
40}