dynamics_spatial/
color.rs1use nalgebra::Vector4;
4
5#[derive(Debug, Clone, Copy, PartialEq)]
6pub struct Color(pub(crate) Vector4<f64>);
8
9impl Color {
10 #[must_use]
12 pub fn new(r: f64, g: f64, b: f64, a: f64) -> Self {
13 Self(Vector4::new(r, g, b, a))
14 }
15
16 #[must_use]
18 pub fn black() -> Self {
19 Self(Vector4::new(0.0, 0.0, 0.0, 1.0))
20 }
21
22 #[must_use]
24 pub fn white() -> Self {
25 Self(Vector4::new(1.0, 1.0, 1.0, 1.0))
26 }
27
28 #[must_use]
30 pub fn transparent() -> Self {
31 Self(Vector4::new(0.0, 0.0, 0.0, 0.0))
32 }
33
34 #[must_use]
35 pub fn as_slice(&self) -> &[f64; 4] {
37 self.0.as_slice().try_into().unwrap()
38 }
39}