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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#[derive(Copy, Clone, Debug)] pub struct Color { pub red: f32, pub green: f32, pub blue: f32, pub alpha: f32, } impl Color { pub fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Self { Self { red, green, blue, alpha, } } } impl Default for Color { fn default() -> Self { Color { red: 1., green: 1., blue: 1., alpha: 1., } } } impl Into<[f32; 4]> for Color { fn into(self) -> [f32; 4] { [self.red, self.green, self.blue, self.alpha] } } impl From<[f32; 4]> for Color { fn from([red, green, blue, alpha]: [f32; 4]) -> Self { Self { red, green, blue, alpha, } } } impl Into<solstice::Color<solstice::ClampedF32>> for Color { fn into(self) -> solstice::Color<solstice::ClampedF32> { solstice::Color { red: self.red.into(), blue: self.blue.into(), green: self.green.into(), alpha: self.alpha.into(), } } } impl Into<mint::Vector4<f32>> for Color { fn into(self) -> mint::Vector4<f32> { mint::Vector4 { x: self.red, y: self.green, z: self.blue, w: self.alpha, } } }