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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! Color representations that contain red, green, and blue components.
//!
//! This module contains:
//!
//! - Traits that work on all RGB data types
//! - Generic types that can be used to define RGB data types
//! - Concrete types that define common RGB data types
//!
//! ## Getting Started
//!
//! If this is your first time using this crate, consider [`crate::prelude`].
//!
//! ```rust
//! // The most common RGB type, used in OpenGL, Vulkan, and web technologies.
//! use gem::rgb::Abgr8888;
//!
//! // 8-bit ARGB color, with alpha first.
//! let red = Abgr8888::from_abgr(128, 0, 0, 255);
//! ```
//!
//! ## Predefined Types
//!
//! [`Abgr8888`] and [`Rgbaf32`] are the most common formats, but there are many others:
//!
//! Type | Bits per pixel | Description
//! ------------ | -------------- | -----------
//! [`Abgr8888`] | 32 | 8 bits each for alpha, blue, green, red
//! [`Argb1555`] | 16 | 5 bits each for RGB, 1 bit alpha
//! [`Argb4444`] | 16 | 4 bits each for RGB, 4 bits alpha
//! [`Argb8888`] | 32 | 8 bits each for alpha, red, green, blue
//! [`Bgr888`] | 24 (32 padded) | 8 bits each for RGB, 8 bits padding in memory
//! [`Rgb565`] | 16 | 5 bits for red, 6 bits for green, 5 bits for blue
//! [`Rgb888`] | 24 (32 padded) | 8 bits each for red, green, blue, 8 bits padding in memory
//! [`Rgbaf32`] | 128 | 32 bits each for red, green, blue, alpha
//! [`Rgbf32`] | 96 | 32 bits each for red, green, blue
//!
//! ## Generic Types
//!
//! Structs with generic types allow easily creating custom RGB types:
//!
//! - [`Rgb<T>`]; a generic RGB color representation stored in order of red, green, blue.
//! - [`Bgr<T>`]; a generic BGR color representation stored in order of blue, green, red.
//!
//! For example, to create an RGB color that stores each channel as a 16-bit integer:
//!
//! ```rust
//! use gem::rgb::Rgb;
//!
//! let red: Rgb<u16> = Rgb::from_rgb(65535, 0, 0);
//! ```
//!
//! For additional types to store alpha channels (such as [`AlphaFirst`][]), see [`crate::alpha`].
//!
//! [`AlphaFirst`]: `crate::alpha::AlphaFirst`
pub use *;
pub use *;
pub use ;
/// A color representation that contains red, green, and blue components.
///
/// ## Layout
///
/// ```c
/// template<typename T>
/// struct Rgb {
/// T r;
/// T g;
/// T b;
/// };
/// ```
unsafe
unsafe
impl_rgb_with_fields!;
/// A color representation that contains blue, green, and red components.
///
/// ## Layout
///
/// ```c
/// template<typename T>
/// struct Bgr {
/// T b;
/// T g;
/// T r;
/// };
/// ```
unsafe
unsafe
impl_rgb_with_fields!;