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
use cgmath::{Vector1, Vector2, Vector3, Vector4};
pub(crate) trait Asu32 {
#[must_use]
fn as_u32(self) -> u32;
}
pub type ColorU8R = Vector1<u8>;
pub type ColorU8RG = Vector2<u8>;
pub type ColorU8RGB = Vector3<u8>;
pub type ColorU8RGBA = Vector4<u8>;
impl Asu32 for ColorU8R {
#[must_use]
fn as_u32(self) -> u32 {
u32::from(self.x)
}
}
impl Asu32 for ColorU8RG {
#[must_use]
fn as_u32(self) -> u32 {
u32::from(self.y) << 8 | u32::from(self.x)
}
}
impl Asu32 for ColorU8RGB {
#[must_use]
fn as_u32(self) -> u32 {
u32::from(self.z) << 16 | u32::from(self.y) << 8 | u32::from(self.x)
}
}
impl Asu32 for ColorU8RGBA {
#[must_use]
fn as_u32(self) -> u32 {
u32::from(self.w) << 24 | u32::from(self.z) << 16 | u32::from(self.y) << 8 | u32::from(self.x)
}
}
pub type ColorU16R = Vector1<u16>;
pub type ColorU16RG = Vector2<u16>;
pub type ColorU16RGB = Vector3<u16>;
pub type ColorU16RGBA = Vector4<u16>;
pub type ColorF32R = Vector1<f32>;
pub type ColorF32RG = Vector2<f32>;
pub type ColorF32RGB = Vector3<f32>;
pub type ColorF32RGBA = Vector4<f32>;