1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/// Colors that represent a single LED. #[derive(Clone, Copy, Debug)] pub struct Rgbw { pub r: u8, pub g: u8, pub b: u8, pub w: u8, } impl Rgbw { /// Shorthand way to create an RGBW instance. pub fn new(r: u8, g: u8, b: u8, w: u8) -> Rgbw { Rgbw { r, g, b, w } } /// An RGBW instance with all values at 0. pub fn black() -> Self { Self::new(0, 0, 0, 0) } /// An RGBW instance with all values maxed out. pub fn white() -> Self { Self::new(255, 255, 255, 255) } }