1 | macro_rules! css_color_types { |
2 | ($( |
3 | $name:ident ($r:literal, $g:literal, $b:literal) |
4 | )*) => { |
5 | use crate::{Color, colors::CustomColor}; |
6 | use core::fmt; |
7 | |
8 | pub(crate) mod dynamic { |
9 | #[cfg(doc)] |
10 | use crate::OwoColorize; |
11 | |
12 | /// Available CSS colors for use with [`OwoColorize::color`](OwoColorize::color) |
13 | /// or [`OwoColorize::on_color`](OwoColorize::on_color) |
14 | #[allow(missing_docs)] |
15 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
16 | pub enum CssColors { |
17 | $($name,)* |
18 | } |
19 | } |
20 | |
21 | use dynamic::CssColors; |
22 | |
23 | impl crate::DynColor for CssColors { |
24 | fn fmt_ansi_fg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
25 | let color = match self { |
26 | $( |
27 | CssColors::$name => CustomColor::<$r, $g, $b>::ANSI_FG, |
28 | )* |
29 | }; |
30 | |
31 | f.write_str(color) |
32 | } |
33 | |
34 | fn fmt_ansi_bg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
35 | let color = match self { |
36 | $( |
37 | CssColors::$name => CustomColor::<$r, $g, $b>::ANSI_BG, |
38 | )* |
39 | }; |
40 | |
41 | f.write_str(color) |
42 | } |
43 | |
44 | fn fmt_raw_ansi_fg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
45 | let color = match self { |
46 | $( |
47 | CssColors::$name => CustomColor::<$r, $g, $b>::RAW_ANSI_FG, |
48 | )* |
49 | }; |
50 | |
51 | f.write_str(color) |
52 | } |
53 | |
54 | fn fmt_raw_ansi_bg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
55 | let color = match self { |
56 | $( |
57 | CssColors::$name => CustomColor::<$r, $g, $b>::RAW_ANSI_BG, |
58 | )* |
59 | }; |
60 | |
61 | f.write_str(color) |
62 | } |
63 | |
64 | #[doc(hidden)] |
65 | fn get_dyncolors_fg(&self) -> crate::DynColors { |
66 | crate::DynColors::Css(*self) |
67 | } |
68 | |
69 | #[doc(hidden)] |
70 | fn get_dyncolors_bg(&self) -> crate::DynColors { |
71 | crate::DynColors::Css(*self) |
72 | } |
73 | } |
74 | |
75 | $( |
76 | #[allow(missing_docs)] |
77 | pub type $name = CustomColor<$r, $g, $b>; |
78 | )* |
79 | }; |
80 | } |
81 | |
82 | css_color_types! { |
83 | AliceBlue (240, 248, 255) |
84 | AntiqueWhite (250, 235, 215) |
85 | Aqua (0, 255, 255) |
86 | Aquamarine (127, 255, 212) |
87 | Azure (240, 255, 255) |
88 | Beige (245, 245, 220) |
89 | Bisque (255, 228, 196) |
90 | Black (0, 0, 0) |
91 | BlanchedAlmond (255, 235, 205) |
92 | Blue (0, 0, 255) |
93 | BlueViolet (138, 43, 226) |
94 | Brown (165, 42, 42) |
95 | BurlyWood (222, 184, 135) |
96 | CadetBlue (95, 158, 160) |
97 | Chartreuse (127, 255, 0) |
98 | Chocolate (210, 105, 30) |
99 | Coral (255, 127, 80) |
100 | CornflowerBlue (100, 149, 237) |
101 | Cornsilk (255, 248, 220) |
102 | Crimson (220, 20, 60) |
103 | DarkBlue (0, 0, 139) |
104 | DarkCyan (0, 139, 139) |
105 | DarkGoldenRod (184, 134, 11) |
106 | DarkGray (169, 169, 169) |
107 | DarkGrey (169, 169, 169) |
108 | DarkGreen (0, 100, 0) |
109 | DarkKhaki (189, 183, 107) |
110 | DarkMagenta (139, 0, 139) |
111 | DarkOliveGreen (85, 107, 47) |
112 | DarkOrange (255, 140, 0) |
113 | DarkOrchid (153, 50, 204) |
114 | DarkRed (139, 0, 0) |
115 | DarkSalmon (233, 150, 122) |
116 | DarkSeaGreen (143, 188, 143) |
117 | DarkSlateBlue (72, 61, 139) |
118 | DarkSlateGray (47, 79, 79) |
119 | DarkSlateGrey (47, 79, 79) |
120 | DarkTurquoise (0, 206, 209) |
121 | DarkViolet (148, 0, 211) |
122 | DeepPink (255, 20, 147) |
123 | DeepSkyBlue (0, 191, 255) |
124 | DimGray (105, 105, 105) |
125 | DimGrey (105, 105, 105) |
126 | DodgerBlue (30, 144, 255) |
127 | FireBrick (178, 34, 34) |
128 | FloralWhite (255, 250, 240) |
129 | ForestGreen (34, 139, 34) |
130 | Fuchsia (255, 0, 255) |
131 | Gainsboro (220, 220, 220) |
132 | GhostWhite (248, 248, 255) |
133 | Gold (255, 215, 0) |
134 | GoldenRod (218, 165, 32) |
135 | Gray (128, 128, 128) |
136 | Grey (128, 128, 128) |
137 | Green (0, 128, 0) |
138 | GreenYellow (173, 255, 47) |
139 | HoneyDew (240, 255, 240) |
140 | HotPink (255, 105, 180) |
141 | IndianRed (205, 92, 92) |
142 | Indigo (75, 0, 130) |
143 | Ivory (255, 255, 240) |
144 | Khaki (240, 230, 140) |
145 | Lavender (230, 230, 250) |
146 | LavenderBlush (255, 240, 245) |
147 | LawnGreen (124, 252, 0) |
148 | LemonChiffon (255, 250, 205) |
149 | LightBlue (173, 216, 230) |
150 | LightCoral (240, 128, 128) |
151 | LightCyan (224, 255, 255) |
152 | LightGoldenRodYellow (250, 250, 210) |
153 | LightGray (211, 211, 211) |
154 | LightGrey (211, 211, 211) |
155 | LightGreen (144, 238, 144) |
156 | LightPink (255, 182, 193) |
157 | LightSalmon (255, 160, 122) |
158 | LightSeaGreen (32, 178, 170) |
159 | LightSkyBlue (135, 206, 250) |
160 | LightSlateGray (119, 136, 153) |
161 | LightSlateGrey (119, 136, 153) |
162 | LightSteelBlue (176, 196, 222) |
163 | LightYellow (255, 255, 224) |
164 | Lime (0, 255, 0) |
165 | LimeGreen (50, 205, 50) |
166 | Linen (250, 240, 230) |
167 | Magenta (255, 0, 255) |
168 | Maroon (128, 0, 0) |
169 | MediumAquaMarine (102, 205, 170) |
170 | MediumBlue (0, 0, 205) |
171 | MediumOrchid (186, 85, 211) |
172 | MediumPurple (147, 112, 219) |
173 | MediumSeaGreen (60, 179, 113) |
174 | MediumSlateBlue (123, 104, 238) |
175 | MediumSpringGreen (0, 250, 154) |
176 | MediumTurquoise (72, 209, 204) |
177 | MediumVioletRed (199, 21, 133) |
178 | MidnightBlue (25, 25, 112) |
179 | MintCream (245, 255, 250) |
180 | MistyRose (255, 228, 225) |
181 | Moccasin (255, 228, 181) |
182 | NavajoWhite (255, 222, 173) |
183 | Navy (0, 0, 128) |
184 | OldLace (253, 245, 230) |
185 | Olive (128, 128, 0) |
186 | OliveDrab (107, 142, 35) |
187 | Orange (255, 165, 0) |
188 | OrangeRed (255, 69, 0) |
189 | Orchid (218, 112, 214) |
190 | PaleGoldenRod (238, 232, 170) |
191 | PaleGreen (152, 251, 152) |
192 | PaleTurquoise (175, 238, 238) |
193 | PaleVioletRed (219, 112, 147) |
194 | PapayaWhip (255, 239, 213) |
195 | PeachPuff (255, 218, 185) |
196 | Peru (205, 133, 63) |
197 | Pink (255, 192, 203) |
198 | Plum (221, 160, 221) |
199 | PowderBlue (176, 224, 230) |
200 | Purple (128, 0, 128) |
201 | RebeccaPurple (102, 51, 153) |
202 | Red (255, 0, 0) |
203 | RosyBrown (188, 143, 143) |
204 | RoyalBlue (65, 105, 225) |
205 | SaddleBrown (139, 69, 19) |
206 | Salmon (250, 128, 114) |
207 | SandyBrown (244, 164, 96) |
208 | SeaGreen (46, 139, 87) |
209 | SeaShell (255, 245, 238) |
210 | Sienna (160, 82, 45) |
211 | Silver (192, 192, 192) |
212 | SkyBlue (135, 206, 235) |
213 | SlateBlue (106, 90, 205) |
214 | SlateGray (112, 128, 144) |
215 | SlateGrey (112, 128, 144) |
216 | Snow (255, 250, 250) |
217 | SpringGreen (0, 255, 127) |
218 | SteelBlue (70, 130, 180) |
219 | Tan (210, 180, 140) |
220 | Teal (0, 128, 128) |
221 | Thistle (216, 191, 216) |
222 | Tomato (255, 99, 71) |
223 | Turquoise (64, 224, 208) |
224 | Violet (238, 130, 238) |
225 | Wheat (245, 222, 179) |
226 | White (255, 255, 255) |
227 | WhiteSmoke (245, 245, 245) |
228 | Yellow (255, 255, 0) |
229 | YellowGreen (154, 205, 50) |
230 | } |
231 | |