Skip to main content

raylib_sys/
color.rs

1//! [`Color`] manipulation helpers
2
3use crate::{Vector3, Vector4};
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7/// A 32-bit RGBA color value with 8 bits per channel.
8///
9/// `Color` is a `#[repr(C)]` struct with fields `r`, `g`, `b`, `a` each in the range `0..=255`.
10/// It maps directly to raylib's `Color` type in C.
11///
12/// A large set of named constants is available via the bundled `Color::RED`, `Color::WHITE`,
13/// `Color::RAYWHITE`, etc. — see the impl block below for the full list. CSS color names are also
14/// available through the [`CSSPalette`] trait and raylib palette names through [`RaylibPalette`].
15///
16/// # Examples
17///
18/// ```rust
19/// use raylib_sys::Color;
20///
21/// // Construct a color and compare against a named constant
22/// let red = Color::new(255, 0, 0, 255);
23/// assert_eq!(red, Color::RED);
24///
25/// // Use alpha() to get a semi-transparent variant
26/// let semi = Color::RED.alpha(0.5);
27/// assert!(semi.a < 200);
28/// ```
29#[repr(C)]
30#[derive(Debug, Copy, Clone, Default)]
31#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
32pub struct Color {
33    pub r: u8,
34    pub g: u8,
35    pub b: u8,
36    pub a: u8,
37}
38
39/// A convenience function for making a new `Color`.
40#[inline]
41pub const fn rcolor(r: u8, g: u8, b: u8, a: u8) -> Color {
42    Color::new(r, g, b, a)
43}
44
45impl From<Color> for Vector4 {
46    fn from(v: Color) -> Self {
47        Vector4 {
48            x: v.r as f32 / 255.0,
49            y: v.g as f32 / 255.0,
50            z: v.b as f32 / 255.0,
51            w: v.a as f32 / 255.0,
52        }
53    }
54}
55
56impl From<(u8, u8, u8, u8)> for Color {
57    fn from(col: (u8, u8, u8, u8)) -> Color {
58        Color::new(col.0, col.1, col.2, col.3)
59    }
60}
61
62impl Color {
63    /// produces Color from a hex string(6 characters long)
64    pub fn from_hex(color_hex_str: &str) -> Result<Color, core::num::ParseIntError> {
65        let color = i32::from_str_radix(color_hex_str, 16)?;
66        let b = color % 0x100;
67        let g = (color - b) / 0x100 % 0x100;
68        let r = (color - g) / 0x10000;
69
70        Ok(Color {
71            r: r as u8,
72            g: g as u8,
73            b: b as u8,
74            a: 255,
75        })
76    }
77
78    #[inline]
79    pub const fn new(r: u8, g: u8, b: u8, a: u8) -> Color {
80        Color { r, g, b, a }
81    }
82
83    /// Get hexadecimal value for a Color (0xRRGGBBAA)
84    #[inline]
85    pub fn color_to_int(&self) -> i32 {
86        unsafe { super::ColorToInt(*self) }
87    }
88
89    /// Get Color normalized as float [0..1]
90    #[inline]
91    pub fn color_normalize(&self) -> Vector4 {
92        unsafe { super::ColorNormalize(*self) }
93    }
94
95    /// Get HSV values for a Color, hue [0..360], saturation/value [0..1]
96    #[inline]
97    pub fn color_to_hsv(&self) -> Vector3 {
98        unsafe { super::ColorToHSV(*self) }
99    }
100
101    /// Get a Color from HSV values, hue [0..360], saturation/value [0..1]
102    #[inline]
103    pub fn color_from_hsv(hue: f32, saturation: f32, value: f32) -> Color {
104        unsafe { super::ColorFromHSV(hue, saturation, value) }
105    }
106
107    /// Get Color from normalized values [0..1]
108    #[inline]
109    pub fn color_from_normalized(normalized: Vector4) -> Color {
110        unsafe { super::ColorFromNormalized(normalized) }
111    }
112
113    /// Get Color structure from hexadecimal value
114    #[inline]
115    pub fn get_color(hex_value: u32) -> Color {
116        unsafe { super::GetColor(hex_value) }
117    }
118
119    /// Get color multiplied with another color
120    #[inline]
121    pub fn tint(&self, color: Self) -> Self {
122        unsafe { super::ColorTint(*self, color) }
123    }
124    /// Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
125    #[inline]
126    pub fn brightness(&self, factor: f32) -> Self {
127        unsafe { super::ColorBrightness(*self, factor) }
128    }
129    /// Get color with contrast correction, contrast values between -1.0f and 1.0f
130    #[inline]
131    pub fn contrast(&self, factor: f32) -> Self {
132        unsafe { super::ColorContrast(*self, factor) }
133    }
134    /// Get color with alpha applied, alpha goes from 0.0f to 1.0f
135    #[inline]
136    pub fn alpha(&self, alpha: f32) -> Self {
137        unsafe { super::ColorAlpha(*self, alpha) }
138    }
139
140    /// Get color with alpha applied, alpha goes from 0.0f to 1.0f
141    #[deprecated = "Use Color::alpha instead"]
142    pub fn fade(&self, alpha: f32) -> Self {
143        unsafe { super::Fade(*self, alpha) }
144    }
145
146    /// Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
147    #[inline]
148    pub fn color_alpha_blend(dst: &Color, src: &Color, tint: &Color) -> Color {
149        unsafe { super::ColorAlphaBlend(*dst, *src, *tint) }
150    }
151    /// Check if two colors are equal
152    #[inline]
153    pub fn is_equal(&self, rhs: impl Into<super::Color>) -> bool {
154        unsafe { super::ColorIsEqual(*self, rhs.into()) }
155    }
156
157    /// Get color lerp interpolation between two colors, factor [0.0f..1.0f]
158    #[inline]
159    pub fn lerp(&self, rhs: Color, factor: f32) -> Color {
160        unsafe { super::ColorLerp(*self, rhs, factor) }
161    }
162}
163
164/// NOTE(IOI_XD): We manually implement PartialEq as of 5.5 to use Raylib's function. It's very unlikely it will ever
165/// change or do anything different, but in the ultra rare case that it does, we want to mimic Raylib's behavior.
166impl PartialEq for Color {
167    fn eq(&self, other: &Self) -> bool {
168        self.is_equal(*other)
169    }
170}
171impl Eq for Color {}
172
173#[rustfmt::skip]
174/// Some Basic Colors
175/// NOTE: Custom raylib color palette for amazing visuals on WHITE background
176pub trait RaylibPalette {
177    /** Light Gray                 */ const LIGHTGRAY:  Color = Color::new(200, 200, 200, 255);
178    /** Gray                       */ const GRAY:       Color = Color::new(130, 130, 130, 255);
179    /** Dark Gray                  */ const DARKGRAY:   Color = Color::new( 80,  80,  80, 255);
180    /** Yellow                     */ const YELLOW:     Color = Color::new(253, 249,   0, 255);
181    /** Gold                       */ const GOLD:       Color = Color::new(255, 203,   0, 255);
182    /** Orange                     */ const ORANGE:     Color = Color::new(255, 161,   0, 255);
183    /** Pink                       */ const PINK:       Color = Color::new(255, 109, 194, 255);
184    /** Red                        */ const RED:        Color = Color::new(230,  41,  55, 255);
185    /** Maroon                     */ const MAROON:     Color = Color::new(190,  33,  55, 255);
186    /** Green                      */ const GREEN:      Color = Color::new(  0, 228,  48, 255);
187    /** Lime                       */ const LIME:       Color = Color::new(  0, 158,  47, 255);
188    /** Dark Green                 */ const DARKGREEN:  Color = Color::new(  0, 117,  44, 255);
189    /** Sky Blue                   */ const SKYBLUE:    Color = Color::new(102, 191, 255, 255);
190    /** Blue                       */ const BLUE:       Color = Color::new(  0, 121, 241, 255);
191    /** Dark Blue                  */ const DARKBLUE:   Color = Color::new(  0,  82, 172, 255);
192    /** Purple                     */ const PURPLE:     Color = Color::new(200, 122, 255, 255);
193    /** Violet                     */ const VIOLET:     Color = Color::new(135,  60, 190, 255);
194    /** Dark Purple                */ const DARKPURPLE: Color = Color::new(112,  31, 126, 255);
195    /** Beige                      */ const BEIGE:      Color = Color::new(211, 176, 131, 255);
196    /** Brown                      */ const BROWN:      Color = Color::new(127, 106,  79, 255);
197    /** Dark Brown                 */ const DARKBROWN:  Color = Color::new( 76,  63,  47, 255);
198
199    /** White                      */ const WHITE:      Color = Color::new(255, 255, 255, 255);
200    /** Black                      */ const BLACK:      Color = Color::new(  0,   0,   0, 255);
201    /** Blank (Transparent)        */ const BLANK:      Color = Color::new(  0,   0,   0,   0);
202    /** Magenta                    */ const MAGENTA:    Color = Color::new(255,   0, 255, 255);
203    /** My own White (raylib logo) */ const RAYWHITE:   Color = Color::new(245, 245, 245, 255);
204}
205impl RaylibPalette for Color {}
206
207#[rustfmt::skip]
208/// CSS Color constants
209pub trait CSSPalette {
210    /** #f0f8ffff */ const ALICEBLUE:            Color = Color::new(0xf0, 0xf8, 0xff, 0xff);
211    /** #faebd7ff */ const ANTIQUEWHITE:         Color = Color::new(0xfa, 0xeb, 0xd7, 0xff);
212    /** #00ffffff */ const AQUA:                 Color = Color::new(0x00, 0xff, 0xff, 0xff);
213    /** #7fffd4ff */ const AQUAMARINE:           Color = Color::new(0x7f, 0xff, 0xd4, 0xff);
214    /** #f0ffffff */ const AZURE:                Color = Color::new(0xf0, 0xff, 0xff, 0xff);
215    /** #f5f5dcff */ const BEIGE:                Color = Color::new(0xf5, 0xf5, 0xdc, 0xff);
216    /** #ffe4c4ff */ const BISQUE:               Color = Color::new(0xff, 0xe4, 0xc4, 0xff);
217    /** #000000ff */ const BLACK:                Color = Color::new(0x00, 0x00, 0x00, 0xff);
218    /** #ffebcdff */ const BLANCHEDALMOND:       Color = Color::new(0xff, 0xeb, 0xcd, 0xff);
219    /** #0000ffff */ const BLUE:                 Color = Color::new(0x00, 0x00, 0xff, 0xff);
220    /** #8a2be2ff */ const BLUEVIOLET:           Color = Color::new(0x8a, 0x2b, 0xe2, 0xff);
221    /** #a52a2aff */ const BROWN:                Color = Color::new(0xa5, 0x2a, 0x2a, 0xff);
222    /** #deb887ff */ const BURLYWOOD:            Color = Color::new(0xde, 0xb8, 0x87, 0xff);
223    /** #5f9ea0ff */ const CADETBLUE:            Color = Color::new(0x5f, 0x9e, 0xa0, 0xff);
224    /** #7fff00ff */ const CHARTREUSE:           Color = Color::new(0x7f, 0xff, 0x00, 0xff);
225    /** #d2691eff */ const CHOCOLATE:            Color = Color::new(0xd2, 0x69, 0x1e, 0xff);
226    /** #ff7f50ff */ const CORAL:                Color = Color::new(0xff, 0x7f, 0x50, 0xff);
227    /** #6495edff */ const CORNFLOWERBLUE:       Color = Color::new(0x64, 0x95, 0xed, 0xff);
228    /** #fff8dcff */ const CORNSILK:             Color = Color::new(0xff, 0xf8, 0xdc, 0xff);
229    /** #dc143cff */ const CRIMSON:              Color = Color::new(0xdc, 0x14, 0x3c, 0xff);
230    /** #00ffffff */ const CYAN:                 Color = Self::AQUA;
231    /** #00008bff */ const DARKBLUE:             Color = Color::new(0x00, 0x00, 0x8b, 0xff);
232    /** #008b8bff */ const DARKCYAN:             Color = Color::new(0x00, 0x8b, 0x8b, 0xff);
233    /** #b8860bff */ const DARKGOLDENROD:        Color = Color::new(0xb8, 0x86, 0x0b, 0xff);
234    /** #a9a9a9ff */ const DARKGRAY:             Color = Color::new(0xa9, 0xa9, 0xa9, 0xff);
235    /** #006400ff */ const DARKGREEN:            Color = Color::new(0x00, 0x64, 0x00, 0xff);
236    /** #a9a9a9ff */ const DARKGREY:             Color = Color::new(0xa9, 0xa9, 0xa9, 0xff);
237    /** #bdb76bff */ const DARKKHAKI:            Color = Color::new(0xbd, 0xb7, 0x6b, 0xff);
238    /** #8b008bff */ const DARKMAGENTA:          Color = Color::new(0x8b, 0x00, 0x8b, 0xff);
239    /** #556b2fff */ const DARKOLIVEGREEN:       Color = Color::new(0x55, 0x6b, 0x2f, 0xff);
240    /** #ff8c00ff */ const DARKORANGE:           Color = Color::new(0xff, 0x8c, 0x00, 0xff);
241    /** #9932ccff */ const DARKORCHID:           Color = Color::new(0x99, 0x32, 0xcc, 0xff);
242    /** #8b0000ff */ const DARKRED:              Color = Color::new(0x8b, 0x00, 0x00, 0xff);
243    /** #e9967aff */ const DARKSALMON:           Color = Color::new(0xe9, 0x96, 0x7a, 0xff);
244    /** #8fbc8fff */ const DARKSEAGREEN:         Color = Color::new(0x8f, 0xbc, 0x8f, 0xff);
245    /** #483d8bff */ const DARKSLATEBLUE:        Color = Color::new(0x48, 0x3d, 0x8b, 0xff);
246    /** #2f4f4fff */ const DARKSLATEGRAY:        Color = Color::new(0x2f, 0x4f, 0x4f, 0xff);
247    /** #2f4f4fff */ const DARKSLATEGREY:        Color = Color::new(0x2f, 0x4f, 0x4f, 0xff);
248    /** #00ced1ff */ const DARKTURQUOISE:        Color = Color::new(0x00, 0xce, 0xd1, 0xff);
249    /** #9400d3ff */ const DARKVIOLET:           Color = Color::new(0x94, 0x00, 0xd3, 0xff);
250    /** #ff1493ff */ const DEEPPINK:             Color = Color::new(0xff, 0x14, 0x93, 0xff);
251    /** #00bfffff */ const DEEPSKYBLUE:          Color = Color::new(0x00, 0xbf, 0xff, 0xff);
252    /** #696969ff */ const DIMGRAY:              Color = Color::new(0x69, 0x69, 0x69, 0xff);
253    /** #696969ff */ const DIMGREY:              Color = Color::new(0x69, 0x69, 0x69, 0xff);
254    /** #1e90ffff */ const DODGERBLUE:           Color = Color::new(0x1e, 0x90, 0xff, 0xff);
255    /** #b22222ff */ const FIREBRICK:            Color = Color::new(0xb2, 0x22, 0x22, 0xff);
256    /** #fffaf0ff */ const FLORALWHITE:          Color = Color::new(0xff, 0xfa, 0xf0, 0xff);
257    /** #228b22ff */ const FORESTGREEN:          Color = Color::new(0x22, 0x8b, 0x22, 0xff);
258    /** #ff00ffff */ const FUCHSIA:              Color = Color::new(0xff, 0x00, 0xff, 0xff);
259    /** #dcdcdcff */ const GAINSBORO:            Color = Color::new(0xdc, 0xdc, 0xdc, 0xff);
260    /** #f8f8ffff */ const GHOSTWHITE:           Color = Color::new(0xf8, 0xf8, 0xff, 0xff);
261    /** #ffd700ff */ const GOLD:                 Color = Color::new(0xff, 0xd7, 0x00, 0xff);
262    /** #daa520ff */ const GOLDENROD:            Color = Color::new(0xda, 0xa5, 0x20, 0xff);
263    /** #808080ff */ const GRAY:                 Color = Color::new(0x80, 0x80, 0x80, 0xff);
264    /** #008000ff */ const GREEN:                Color = Color::new(0x00, 0x80, 0x00, 0xff);
265    /** #adff2fff */ const GREENYELLOW:          Color = Color::new(0xad, 0xff, 0x2f, 0xff);
266    /** #808080ff */ const GREY:                 Color = Self::GRAY;
267    /** #f0fff0ff */ const HONEYDEW:             Color = Color::new(0xf0, 0xff, 0xf0, 0xff);
268    /** #ff69b4ff */ const HOTPINK:              Color = Color::new(0xff, 0x69, 0xb4, 0xff);
269    /** #cd5c5cff */ const INDIANRED:            Color = Color::new(0xcd, 0x5c, 0x5c, 0xff);
270    /** #4b0082ff */ const INDIGO:               Color = Color::new(0x4b, 0x00, 0x82, 0xff);
271    /** #fffff0ff */ const IVORY:                Color = Color::new(0xff, 0xff, 0xf0, 0xff);
272    /** #f0e68cff */ const KHAKI:                Color = Color::new(0xf0, 0xe6, 0x8c, 0xff);
273    /** #e6e6faff */ const LAVENDER:             Color = Color::new(0xe6, 0xe6, 0xfa, 0xff);
274    /** #fff0f5ff */ const LAVENDERBLUSH:        Color = Color::new(0xff, 0xf0, 0xf5, 0xff);
275    /** #7cfc00ff */ const LAWNGREEN:            Color = Color::new(0x7c, 0xfc, 0x00, 0xff);
276    /** #fffacdff */ const LEMONCHIFFON:         Color = Color::new(0xff, 0xfa, 0xcd, 0xff);
277    /** #add8e6ff */ const LIGHTBLUE:            Color = Color::new(0xad, 0xd8, 0xe6, 0xff);
278    /** #f08080ff */ const LIGHTCORAL:           Color = Color::new(0xf0, 0x80, 0x80, 0xff);
279    /** #e0ffffff */ const LIGHTCYAN:            Color = Color::new(0xe0, 0xff, 0xff, 0xff);
280    /** #fafad2ff */ const LIGHTGOLDENRODYELLOW: Color = Color::new(0xfa, 0xfa, 0xd2, 0xff);
281    /** #d3d3d3ff */ const LIGHTGRAY:            Color = Color::new(0xd3, 0xd3, 0xd3, 0xff);
282    /** #90ee90ff */ const LIGHTGREEN:           Color = Color::new(0x90, 0xee, 0x90, 0xff);
283    /** #d3d3d3ff */ const LIGHTGREY:            Color = Color::new(0xd3, 0xd3, 0xd3, 0xff);
284    /** #ffb6c1ff */ const LIGHTPINK:            Color = Color::new(0xff, 0xb6, 0xc1, 0xff);
285    /** #ffa07aff */ const LIGHTSALMON:          Color = Color::new(0xff, 0xa0, 0x7a, 0xff);
286    /** #20b2aaff */ const LIGHTSEAGREEN:        Color = Color::new(0x20, 0xb2, 0xaa, 0xff);
287    /** #87cefaff */ const LIGHTSKYBLUE:         Color = Color::new(0x87, 0xce, 0xfa, 0xff);
288    /** #778899ff */ const LIGHTSLATEGRAY:       Color = Color::new(0x77, 0x88, 0x99, 0xff);
289    /** #778899ff */ const LIGHTSLATEGREY:       Color = Color::new(0x77, 0x88, 0x99, 0xff);
290    /** #b0c4deff */ const LIGHTSTEELBLUE:       Color = Color::new(0xb0, 0xc4, 0xde, 0xff);
291    /** #ffffe0ff */ const LIGHTYELLOW:          Color = Color::new(0xff, 0xff, 0xe0, 0xff);
292    /** #00ff00ff */ const LIME:                 Color = Color::new(0x00, 0xff, 0x00, 0xff);
293    /** #32cd32ff */ const LIMEGREEN:            Color = Color::new(0x32, 0xcd, 0x32, 0xff);
294    /** #faf0e6ff */ const LINEN:                Color = Color::new(0xfa, 0xf0, 0xe6, 0xff);
295    /** #ff00ffff */ const MAGENTA:              Color = Self::FUCHSIA;
296    /** #800000ff */ const MAROON:               Color = Color::new(0x80, 0x00, 0x00, 0xff);
297    /** #66cdaaff */ const MEDIUMAQUAMARINE:     Color = Color::new(0x66, 0xcd, 0xaa, 0xff);
298    /** #0000cdff */ const MEDIUMBLUE:           Color = Color::new(0x00, 0x00, 0xcd, 0xff);
299    /** #ba55d3ff */ const MEDIUMORCHID:         Color = Color::new(0xba, 0x55, 0xd3, 0xff);
300    /** #9370dbff */ const MEDIUMPURPLE:         Color = Color::new(0x93, 0x70, 0xdb, 0xff);
301    /** #3cb371ff */ const MEDIUMSEAGREEN:       Color = Color::new(0x3c, 0xb3, 0x71, 0xff);
302    /** #7b68eeff */ const MEDIUMSLATEBLUE:      Color = Color::new(0x7b, 0x68, 0xee, 0xff);
303    /** #00fa9aff */ const MEDIUMSPRINGGREEN:    Color = Color::new(0x00, 0xfa, 0x9a, 0xff);
304    /** #48d1ccff */ const MEDIUMTURQUOISE:      Color = Color::new(0x48, 0xd1, 0xcc, 0xff);
305    /** #c71585ff */ const MEDIUMVIOLETRED:      Color = Color::new(0xc7, 0x15, 0x85, 0xff);
306    /** #191970ff */ const MIDNIGHTBLUE:         Color = Color::new(0x19, 0x19, 0x70, 0xff);
307    /** #f5fffaff */ const MINTCREAM:            Color = Color::new(0xf5, 0xff, 0xfa, 0xff);
308    /** #ffe4e1ff */ const MISTYROSE:            Color = Color::new(0xff, 0xe4, 0xe1, 0xff);
309    /** #ffe4b5ff */ const MOCCASIN:             Color = Color::new(0xff, 0xe4, 0xb5, 0xff);
310    /** #ffdeadff */ const NAVAJOWHITE:          Color = Color::new(0xff, 0xde, 0xad, 0xff);
311    /** #000080ff */ const NAVY:                 Color = Color::new(0x00, 0x00, 0x80, 0xff);
312    /** #fdf5e6ff */ const OLDLACE:              Color = Color::new(0xfd, 0xf5, 0xe6, 0xff);
313    /** #808000ff */ const OLIVE:                Color = Color::new(0x80, 0x80, 0x00, 0xff);
314    /** #6b8e23ff */ const OLIVEDRAB:            Color = Color::new(0x6b, 0x8e, 0x23, 0xff);
315    /** #ffa500ff */ const ORANGE:               Color = Color::new(0xff, 0xa5, 0x00, 0xff);
316    /** #ff4500ff */ const ORANGERED:            Color = Color::new(0xff, 0x45, 0x00, 0xff);
317    /** #da70d6ff */ const ORCHID:               Color = Color::new(0xda, 0x70, 0xd6, 0xff);
318    /** #eee8aaff */ const PALEGOLDENROD:        Color = Color::new(0xee, 0xe8, 0xaa, 0xff);
319    /** #98fb98ff */ const PALEGREEN:            Color = Color::new(0x98, 0xfb, 0x98, 0xff);
320    /** #afeeeeff */ const PALETURQUOISE:        Color = Color::new(0xaf, 0xee, 0xee, 0xff);
321    /** #db7093ff */ const PALEVIOLETRED:        Color = Color::new(0xdb, 0x70, 0x93, 0xff);
322    /** #ffefd5ff */ const PAPAYAWHIP:           Color = Color::new(0xff, 0xef, 0xd5, 0xff);
323    /** #ffdab9ff */ const PEACHPUFF:            Color = Color::new(0xff, 0xda, 0xb9, 0xff);
324    /** #cd853fff */ const PERU:                 Color = Color::new(0xcd, 0x85, 0x3f, 0xff);
325    /** #ffc0cbff */ const PINK:                 Color = Color::new(0xff, 0xc0, 0xcb, 0xff);
326    /** #dda0ddff */ const PLUM:                 Color = Color::new(0xdd, 0xa0, 0xdd, 0xff);
327    /** #b0e0e6ff */ const POWDERBLUE:           Color = Color::new(0xb0, 0xe0, 0xe6, 0xff);
328    /** #800080ff */ const PURPLE:               Color = Color::new(0x80, 0x00, 0x80, 0xff);
329    /** #663399ff */ const REBECCAPURPLE:        Color = Color::new(0x66, 0x33, 0x99, 0xff);
330    /** #ff0000ff */ const RED:                  Color = Color::new(0xff, 0x00, 0x00, 0xff);
331    /** #bc8f8fff */ const ROSYBROWN:            Color = Color::new(0xbc, 0x8f, 0x8f, 0xff);
332    /** #4169e1ff */ const ROYALBLUE:            Color = Color::new(0x41, 0x69, 0xe1, 0xff);
333    /** #8b4513ff */ const SADDLEBROWN:          Color = Color::new(0x8b, 0x45, 0x13, 0xff);
334    /** #fa8072ff */ const SALMON:               Color = Color::new(0xfa, 0x80, 0x72, 0xff);
335    /** #f4a460ff */ const SANDYBROWN:           Color = Color::new(0xf4, 0xa4, 0x60, 0xff);
336    /** #2e8b57ff */ const SEAGREEN:             Color = Color::new(0x2e, 0x8b, 0x57, 0xff);
337    /** #fff5eeff */ const SEASHELL:             Color = Color::new(0xff, 0xf5, 0xee, 0xff);
338    /** #a0522dff */ const SIENNA:               Color = Color::new(0xa0, 0x52, 0x2d, 0xff);
339    /** #c0c0c0ff */ const SILVER:               Color = Color::new(0xc0, 0xc0, 0xc0, 0xff);
340    /** #87ceebff */ const SKYBLUE:              Color = Color::new(0x87, 0xce, 0xeb, 0xff);
341    /** #6a5acdff */ const SLATEBLUE:            Color = Color::new(0x6a, 0x5a, 0xcd, 0xff);
342    /** #708090ff */ const SLATEGRAY:            Color = Color::new(0x70, 0x80, 0x90, 0xff);
343    /** #708090ff */ const SLATEGREY:            Color = Color::new(0x70, 0x80, 0x90, 0xff);
344    /** #fffafaff */ const SNOW:                 Color = Color::new(0xff, 0xfa, 0xfa, 0xff);
345    /** #00ff7fff */ const SPRINGGREEN:          Color = Color::new(0x00, 0xff, 0x7f, 0xff);
346    /** #4682b4ff */ const STEELBLUE:            Color = Color::new(0x46, 0x82, 0xb4, 0xff);
347    /** #d2b48cff */ const TAN:                  Color = Color::new(0xd2, 0xb4, 0x8c, 0xff);
348    /** #008080ff */ const TEAL:                 Color = Color::new(0x00, 0x80, 0x80, 0xff);
349    /** #d8bfd8ff */ const THISTLE:              Color = Color::new(0xd8, 0xbf, 0xd8, 0xff);
350    /** #00000000 */ const TRANSPARENT:          Color = Color::new(0x00, 0x00, 0x00, 0x00);
351    /** #ff6347ff */ const TOMATO:               Color = Color::new(0xff, 0x63, 0x47, 0xff);
352    /** #40e0d0ff */ const TURQUOISE:            Color = Color::new(0x40, 0xe0, 0xd0, 0xff);
353    /** #ee82eeff */ const VIOLET:               Color = Color::new(0xee, 0x82, 0xee, 0xff);
354    /** #f5deb3ff */ const WHEAT:                Color = Color::new(0xf5, 0xde, 0xb3, 0xff);
355    /** #ffffffff */ const WHITE:                Color = Color::new(0xff, 0xff, 0xff, 0xff);
356    /** #f5f5f5ff */ const WHITESMOKE:           Color = Color::new(0xf5, 0xf5, 0xf5, 0xff);
357    /** #ffff00ff */ const YELLOW:               Color = Color::new(0xff, 0xff, 0x00, 0xff);
358    /** #9acd32ff */ const YELLOWGREEN:          Color = Color::new(0x9a, 0xcd, 0x32, 0xff);
359}
360impl CSSPalette for Color {}
361
362#[rustfmt::skip]
363/// Color constants
364impl Color {
365    pub const INDIANRED: Color = Color::new(205, 92, 92, 255);
366    pub const LIGHTCORAL: Color = Color::new(240, 128, 128, 255);
367    pub const SALMON: Color = Color::new(250, 128, 114, 255);
368    pub const DARKSALMON: Color = Color::new(233, 150, 122, 255);
369    pub const LIGHTSALMON: Color = Color::new(255, 160, 122, 255);
370    pub const CRIMSON: Color = Color::new(220, 20, 60, 255);
371    pub const RED: Color = Color::new(255, 0, 0, 255);
372    pub const FIREBRICK: Color = Color::new(178, 34, 34, 255);
373    pub const DARKRED: Color = Color::new(139, 0, 0, 255);
374    pub const PINK: Color = Color::new(255, 192, 203, 255);
375    pub const LIGHTPINK: Color = Color::new(255, 182, 193, 255);
376    pub const HOTPINK: Color = Color::new(255, 105, 180, 255);
377    pub const DEEPPINK: Color = Color::new(255, 20, 147, 255);
378    pub const MEDIUMVIOLETRED: Color = Color::new(199, 21, 133, 255);
379    pub const PALEVIOLETRED: Color = Color::new(219, 112, 147, 255);
380    pub const CORAL: Color = Color::new(255, 127, 80, 255);
381    pub const TOMATO: Color = Color::new(255, 99, 71, 255);
382    pub const ORANGERED: Color = Color::new(255, 69, 0, 255);
383    pub const DARKORANGE: Color = Color::new(255, 140, 0, 255);
384    pub const ORANGE: Color = Color::new(255, 165, 0, 255);
385    pub const GOLD: Color = Color::new(255, 215, 0, 255);
386    pub const YELLOW: Color = Color::new(255, 255, 0, 255);
387    pub const LIGHTYELLOW: Color = Color::new(255, 255, 224, 255);
388    pub const LEMONCHIFFON: Color = Color::new(255, 250, 205, 255);
389    pub const LIGHTGOLDENRODYELLOW: Color = Color::new(250, 250, 210, 255);
390    pub const PAPAYAWHIP: Color = Color::new(255, 239, 213, 255);
391    pub const MOCCASIN: Color = Color::new(255, 228, 181, 255);
392    pub const PEACHPUFF: Color = Color::new(255, 218, 185, 255);
393    pub const PALEGOLDENROD: Color = Color::new(238, 232, 170, 255);
394    pub const KHAKI: Color = Color::new(240, 230, 140, 255);
395    pub const DARKKHAKI: Color = Color::new(189, 183, 107, 255);
396    pub const LAVENDER: Color = Color::new(230, 230, 250, 255);
397    pub const THISTLE: Color = Color::new(216, 191, 216, 255);
398    pub const PLUM: Color = Color::new(221, 160, 221, 255);
399    pub const VIOLET: Color = Color::new(238, 130, 238, 255);
400    pub const ORCHID: Color = Color::new(218, 112, 214, 255);
401    pub const FUCHSIA: Color = Color::new(255, 0, 255, 255);
402    pub const MAGENTA: Color = Color::new(255, 0, 255, 255);
403    pub const MEDIUMORCHID: Color = Color::new(186, 85, 211, 255);
404    pub const MEDIUMPURPLE: Color = Color::new(147, 112, 219, 255);
405    pub const REBECCAPURPLE: Color = Color::new(102, 51, 153, 255);
406    pub const BLUEVIOLET: Color = Color::new(138, 43, 226, 255);
407    pub const DARKVIOLET: Color = Color::new(148, 0, 211, 255);
408    pub const DARKORCHID: Color = Color::new(153, 50, 204, 255);
409    pub const DARKMAGENTA: Color = Color::new(139, 0, 139, 255);
410    pub const PURPLE: Color = Color::new(128, 0, 128, 255);
411    pub const DARKPURPLE: Color = Color::new(112, 31, 126, 255);
412    pub const INDIGO: Color = Color::new(75, 0, 130, 255);
413    pub const SLATEBLUE: Color = Color::new(106, 90, 205, 255);
414    pub const DARKSLATEBLUE: Color = Color::new(72, 61, 139, 255);
415    pub const MEDIUMSLATEBLUE: Color = Color::new(123, 104, 238, 255);
416    pub const GREENYELLOW: Color = Color::new(173, 255, 47, 255);
417    pub const CHARTREUSE: Color = Color::new(127, 255, 0, 255);
418    pub const LAWNGREEN: Color = Color::new(124, 252, 0, 255);
419    pub const LIME: Color = Color::new(0, 255, 0, 255);
420    pub const LIMEGREEN: Color = Color::new(50, 205, 50, 255);
421    pub const PALEGREEN: Color = Color::new(152, 251, 152, 255);
422    pub const LIGHTGREEN: Color = Color::new(144, 238, 144, 255);
423    pub const MEDIUMSPRINGGREEN: Color = Color::new(0, 250, 154, 255);
424    pub const SPRINGGREEN: Color = Color::new(0, 255, 127, 255);
425    pub const MEDIUMSEAGREEN: Color = Color::new(60, 179, 113, 255);
426    pub const SEAGREEN: Color = Color::new(46, 139, 87, 255);
427    pub const FORESTGREEN: Color = Color::new(34, 139, 34, 255);
428    pub const GREEN: Color = Color::new(0, 128, 0, 255);
429    pub const DARKGREEN: Color = Color::new(0, 100, 0, 255);
430    pub const YELLOWGREEN: Color = Color::new(154, 205, 50, 255);
431    pub const OLIVEDRAB: Color = Color::new(107, 142, 35, 255);
432    pub const OLIVE: Color = Color::new(128, 128, 0, 255);
433    pub const DARKOLIVEGREEN: Color = Color::new(85, 107, 47, 255);
434    pub const MEDIUMAQUAMARINE: Color = Color::new(102, 205, 170, 255);
435    pub const DARKSEAGREEN: Color = Color::new(143, 188, 139, 255);
436    pub const LIGHTSEAGREEN: Color = Color::new(32, 178, 170, 255);
437    pub const DARKCYAN: Color = Color::new(0, 139, 139, 255);
438    pub const TEAL: Color = Color::new(0, 128, 128, 255);
439    pub const AQUA: Color = Color::new(0, 255, 255, 255);
440    pub const CYAN: Color = Color::new(0, 255, 255, 255);
441    pub const LIGHTCYAN: Color = Color::new(224, 255, 255, 255);
442    pub const PALETURQUOISE: Color = Color::new(175, 238, 238, 255);
443    pub const AQUAMARINE: Color = Color::new(127, 255, 212, 255);
444    pub const TURQUOISE: Color = Color::new(64, 224, 208, 255);
445    pub const MEDIUMTURQUOISE: Color = Color::new(72, 209, 204, 255);
446    pub const DARKTURQUOISE: Color = Color::new(0, 206, 209, 255);
447    pub const CADETBLUE: Color = Color::new(95, 158, 160, 255);
448    pub const STEELBLUE: Color = Color::new(70, 130, 180, 255);
449    pub const LIGHTSTEELBLUE: Color = Color::new(176, 196, 222, 255);
450    pub const POWDERBLUE: Color = Color::new(176, 224, 230, 255);
451    pub const LIGHTBLUE: Color = Color::new(173, 216, 230, 255);
452    pub const SKYBLUE: Color = Color::new(135, 206, 235, 255);
453    pub const LIGHTSKYBLUE: Color = Color::new(135, 206, 250, 255);
454    pub const DEEPSKYBLUE: Color = Color::new(0, 191, 255, 255);
455    pub const DODGERBLUE: Color = Color::new(30, 144, 255, 255);
456    pub const CORNFLOWERBLUE: Color = Color::new(100, 149, 237, 255);
457    pub const ROYALBLUE: Color = Color::new(65, 105, 225, 255);
458    pub const BLUE: Color = Color::new(0, 0, 255, 255);
459    pub const MEDIUMBLUE: Color = Color::new(0, 0, 205, 255);
460    pub const DARKBLUE: Color = Color::new(0, 0, 139, 255);
461    pub const NAVY: Color = Color::new(0, 0, 128, 255);
462    pub const MIDNIGHTBLUE: Color = Color::new(25, 25, 112, 255);
463    pub const CORNSILK: Color = Color::new(255, 248, 220, 255);
464    pub const BLANCHEDALMOND: Color = Color::new(255, 235, 205, 255);
465    pub const BISQUE: Color = Color::new(255, 228, 196, 255);
466    pub const NAVAJOWHITE: Color = Color::new(255, 222, 173, 255);
467    pub const WHEAT: Color = Color::new(245, 222, 179, 255);
468    pub const BURLYWOOD: Color = Color::new(222, 184, 135, 255);
469    pub const TAN: Color = Color::new(210, 180, 140, 255);
470    pub const ROSYBROWN: Color = Color::new(188, 143, 143, 255);
471    pub const SANDYBROWN: Color = Color::new(244, 164, 96, 255);
472    pub const GOLDENROD: Color = Color::new(218, 165, 32, 255);
473    pub const DARKGOLDENROD: Color = Color::new(184, 134, 11, 255);
474    pub const PERU: Color = Color::new(205, 133, 63, 255);
475    pub const CHOCOLATE: Color = Color::new(210, 105, 30, 255);
476    pub const SADDLEBROWN: Color = Color::new(139, 69, 19, 255);
477    pub const SIENNA: Color = Color::new(160, 82, 45, 255);
478    pub const BROWN: Color = Color::new(165, 42, 42, 255);
479    pub const DARKBROWN: Color = Color::new(76, 63, 47, 255);
480    pub const MAROON: Color = Color::new(128, 0, 0, 255);
481    pub const WHITE: Color = Color::new(255, 255, 255, 255);
482    pub const SNOW: Color = Color::new(255, 250, 250, 255);
483    pub const HONEYDEW: Color = Color::new(240, 255, 240, 255);
484    pub const MINTCREAM: Color = Color::new(245, 255, 250, 255);
485    pub const AZURE: Color = Color::new(240, 255, 255, 255);
486    pub const ALICEBLUE: Color = Color::new(240, 248, 255, 255);
487    pub const GHOSTWHITE: Color = Color::new(248, 248, 255, 255);
488    pub const WHITESMOKE: Color = Color::new(245, 245, 245, 255);
489    pub const SEASHELL: Color = Color::new(255, 245, 238, 255);
490    pub const BEIGE: Color = Color::new(245, 245, 220, 255);
491    pub const OLDLACE: Color = Color::new(253, 245, 230, 255);
492    pub const FLORALWHITE: Color = Color::new(255, 250, 240, 255);
493    pub const IVORY: Color = Color::new(255, 255, 240, 255);
494    pub const ANTIQUEWHITE: Color = Color::new(250, 235, 215, 255);
495    pub const LINEN: Color = Color::new(250, 240, 230, 255);
496    pub const LAVENDERBLUSH: Color = Color::new(255, 240, 245, 255);
497    pub const MISTYROSE: Color = Color::new(255, 228, 225, 255);
498    pub const GAINSBORO: Color = Color::new(220, 220, 220, 255);
499    pub const LIGHTGRAY: Color = Color::new(211, 211, 211, 255);
500    pub const SILVER: Color = Color::new(192, 192, 192, 255);
501    pub const DARKGRAY: Color = Color::new(169, 169, 169, 255);
502    pub const GRAY: Color = Color::new(128, 128, 128, 255);
503    pub const DIMGRAY: Color = Color::new(105, 105, 105, 255);
504    pub const LIGHTSLATEGRAY: Color = Color::new(119, 136, 153, 255);
505    pub const SLATEGRAY: Color = Color::new(112, 128, 144, 255);
506    pub const DARKSLATEGRAY: Color = Color::new(47, 79, 79, 255);
507    pub const BLACK: Color = Color::new(0, 0, 0, 255);
508    pub const BLANK: Color = Color::new(0, 0, 0, 0);
509    pub const RAYWHITE: Color = Color::new(245, 245, 245, 255);
510}