1 | // (c) Dean McNamee <dean@gmail.com>, 2012. |
2 | // (c) Rust port by Katkov Oleksandr <alexx.katkoff@gmail.com>, 2016. |
3 | // |
4 | // https://github.com/deanm/css-color-parser-js |
5 | // https://github.com/7thSigil/css-color-parser-rs |
6 | // |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | // of this software and associated documentation files (the "Software"), to |
9 | // deal in the Software without restriction, including without limitation the |
10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
11 | // sell copies of the Software, and to permit persons to whom the Software is |
12 | // furnished to do so, subject to the following conditions: |
13 | // |
14 | // The above copyright notice and this permission notice shall be included in |
15 | // all copies or substantial portions of the Software. |
16 | // |
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
23 | // IN THE SOFTWARE. |
24 | |
25 | use std::collections::HashMap; |
26 | use crate::color::color::Color; |
27 | |
28 | lazy_static::lazy_static! { |
29 | /// List of CSS3 named colors from http://www.w3.org/TR/css3-color. |
30 | pub static ref NAMED_COLORS: HashMap<&'static str, Color> = { |
31 | let mut m = HashMap::new(); |
32 | m.insert("transparent" , Color { r: 0, g: 0, b: 0, a: 0.0 }); |
33 | m.insert("aliceblue" , Color { r: 240, g: 248, b: 255, a: 1.0 }); |
34 | m.insert("antiquewhite" , Color { r: 250, g: 235, b: 215, a: 1.0 }); |
35 | m.insert("aqua" , Color { r: 0, g: 255, b: 255, a: 1.0 }); |
36 | m.insert("aquamarine" , Color { r: 127, g: 255, b: 212, a: 1.0 }); |
37 | m.insert("azure" , Color { r: 240, g: 255, b: 255, a: 1.0 }); |
38 | m.insert("beige" , Color { r: 245, g: 245, b: 220, a: 1.0 }); |
39 | m.insert("bisque" , Color { r: 255, g: 228, b: 196, a: 1.0 }); |
40 | m.insert("black" , Color { r: 0, g: 0, b: 0, a: 1.0 }); |
41 | m.insert("blanchedalmond" , Color { r: 255, g: 235, b: 205, a: 1.0 }); |
42 | m.insert("blue" , Color { r: 0, g: 0, b: 255, a: 1.0 }); |
43 | m.insert("blueviolet" , Color { r: 138, g: 43, b: 226, a: 1.0 }); |
44 | m.insert("brown" , Color { r: 165, g: 42, b: 42, a: 1.0 }); |
45 | m.insert("burlywood" , Color { r: 222, g: 184, b: 135, a: 1.0 }); |
46 | m.insert("cadetblue" , Color { r: 95, g: 158, b: 160, a: 1.0 }); |
47 | m.insert("chartreuse" , Color { r: 127, g: 255, b: 0, a: 1.0 }); |
48 | m.insert("chocolate" , Color { r: 210, g: 105, b: 30, a: 1.0 }); |
49 | m.insert("coral" , Color { r: 255, g: 127, b: 80, a: 1.0 }); |
50 | m.insert("cornflowerblue" , Color { r: 100, g: 149, b: 237, a: 1.0 }); |
51 | m.insert("cornsilk" , Color { r: 255, g: 248, b: 220, a: 1.0 }); |
52 | m.insert("crimson" , Color { r: 220, g: 20, b: 60, a: 1.0 }); |
53 | m.insert("cyan" , Color { r: 0, g: 255, b: 255, a: 1.0 }); |
54 | m.insert("darkblue" , Color { r: 0, g: 0, b: 139, a: 1.0 }); |
55 | m.insert("darkcyan" , Color { r: 0, g: 139, b: 139, a: 1.0 }); |
56 | m.insert("darkgoldenrod" , Color { r: 184, g: 134, b: 11, a: 1.0 }); |
57 | m.insert("darkgray" , Color { r: 169, g: 169, b: 169, a: 1.0 }); |
58 | m.insert("darkgreen" , Color { r: 0, g: 100, b: 0, a: 1.0 }); |
59 | m.insert("darkgrey" , Color { r: 169, g: 169, b: 169, a: 1.0 }); |
60 | m.insert("darkkhaki" , Color { r: 189, g: 183, b: 107, a: 1.0 }); |
61 | m.insert("darkmagenta" , Color { r: 139, g: 0, b: 139, a: 1.0 }); |
62 | m.insert("darkolivegreen" , Color { r: 85, g: 107, b: 47, a: 1.0 }); |
63 | m.insert("darkorange" , Color { r: 255, g: 140, b: 0, a: 1.0 }); |
64 | m.insert("darkorchid" , Color { r: 153, g: 50, b: 204, a: 1.0 }); |
65 | m.insert("darkred" , Color { r: 139, g: 0, b: 0, a: 1.0 }); |
66 | m.insert("darksalmon" , Color { r: 233, g: 150, b: 122, a: 1.0 }); |
67 | m.insert("darkseagreen" , Color { r: 143, g: 188, b: 143, a: 1.0 }); |
68 | m.insert("darkslateblue" , Color { r: 72, g: 61, b: 139, a: 1.0 }); |
69 | m.insert("darkslategray" , Color { r: 47, g: 79, b: 79, a: 1.0 }); |
70 | m.insert("darkslategrey" , Color { r: 47, g: 79, b: 79, a: 1.0 }); |
71 | m.insert("darkturquoise" , Color { r: 0, g: 206, b: 209, a: 1.0 }); |
72 | m.insert("darkviolet" , Color { r: 148, g: 0, b: 211, a: 1.0 }); |
73 | m.insert("deeppink" , Color { r: 255, g: 20, b: 147, a: 1.0 }); |
74 | m.insert("deepskyblue" , Color { r: 0, g: 191, b: 255, a: 1.0 }); |
75 | m.insert("dimgray" , Color { r: 105, g: 105, b: 105, a: 1.0 }); |
76 | m.insert("dimgrey" , Color { r: 105, g: 105, b: 105, a: 1.0 }); |
77 | m.insert("dodgerblue" , Color { r: 30, g: 144, b: 255, a: 1.0 }); |
78 | m.insert("firebrick" , Color { r: 178, g: 34, b: 34, a: 1.0 }); |
79 | m.insert("floralwhite" , Color { r: 255, g: 250, b: 240, a: 1.0 }); |
80 | m.insert("forestgreen" , Color { r: 34, g: 139, b: 34, a: 1.0 }); |
81 | m.insert("fuchsia" , Color { r: 255, g: 0, b: 255, a: 1.0 }); |
82 | m.insert("gainsboro" , Color { r: 220, g: 220, b: 220, a: 1.0 }); |
83 | m.insert("ghostwhite" , Color { r: 248, g: 248, b: 255, a: 1.0 }); |
84 | m.insert("gold" , Color { r: 255, g: 215, b: 0, a: 1.0 }); |
85 | m.insert("goldenrod" , Color { r: 218, g: 165, b: 32, a: 1.0 }); |
86 | m.insert("gray" , Color { r: 128, g: 128, b: 128, a: 1.0 }); |
87 | m.insert("green" , Color { r: 0, g: 128, b: 0, a: 1.0 }); |
88 | m.insert("greenyellow" , Color { r: 173, g: 255, b: 47, a: 1.0 }); |
89 | m.insert("grey" , Color { r: 128, g: 128, b: 128, a: 1.0 }); |
90 | m.insert("honeydew" , Color { r: 240, g: 255, b: 240, a: 1.0 }); |
91 | m.insert("hotpink" , Color { r: 255, g: 105, b: 180, a: 1.0 }); |
92 | m.insert("indianred" , Color { r: 205, g: 92, b: 92, a: 1.0 }); |
93 | m.insert("indigo" , Color { r: 75, g: 0, b: 130, a: 1.0 }); |
94 | m.insert("ivory" , Color { r: 255, g: 255, b: 240, a: 1.0 }); |
95 | m.insert("khaki" , Color { r: 240, g: 230, b: 140, a: 1.0 }); |
96 | m.insert("lavender" , Color { r: 230, g: 230, b: 250, a: 1.0 }); |
97 | m.insert("lavenderblush" , Color { r: 255, g: 240, b: 245, a: 1.0 }); |
98 | m.insert("lawngreen" , Color { r: 124, g: 252, b: 0, a: 1.0 }); |
99 | m.insert("lemonchiffon" , Color { r: 255, g: 250, b: 205, a: 1.0 }); |
100 | m.insert("lightblue" , Color { r: 173, g: 216, b: 230, a: 1.0 }); |
101 | m.insert("lightcoral" , Color { r: 240, g: 128, b: 128, a: 1.0 }); |
102 | m.insert("lightcyan" , Color { r: 224, g: 255, b: 255, a: 1.0 }); |
103 | m.insert("lightgoldenrodyellow" , Color { r: 250, g: 250, b: 210, a: 1.0 }); |
104 | m.insert("lightgray" , Color { r: 211, g: 211, b: 211, a: 1.0 }); |
105 | m.insert("lightgreen" , Color { r: 144, g: 238, b: 144, a: 1.0 }); |
106 | m.insert("lightgrey" , Color { r: 211, g: 211, b: 211, a: 1.0 }); |
107 | m.insert("lightpink" , Color { r: 255, g: 182, b: 193, a: 1.0 }); |
108 | m.insert("lightsalmon" , Color { r: 255, g: 160, b: 122, a: 1.0 }); |
109 | m.insert("lightseagreen" , Color { r: 32, g: 178, b: 170, a: 1.0 }); |
110 | m.insert("lightskyblue" , Color { r: 135, g: 206, b: 250, a: 1.0 }); |
111 | m.insert("lightslategray" , Color { r: 119, g: 136, b: 153, a: 1.0 }); |
112 | m.insert("lightslategrey" , Color { r: 119, g: 136, b: 153, a: 1.0 }); |
113 | m.insert("lightsteelblue" , Color { r: 176, g: 196, b: 222, a: 1.0 }); |
114 | m.insert("lightyellow" , Color { r: 255, g: 255, b: 224, a: 1.0 }); |
115 | m.insert("lime" , Color { r: 0, g: 255, b: 0, a: 1.0 }); |
116 | m.insert("limegreen" , Color { r: 50, g: 205, b: 50, a: 1.0 }); |
117 | m.insert("linen" , Color { r: 250, g: 240, b: 230, a: 1.0 }); |
118 | m.insert("magenta" , Color { r: 255, g: 0, b: 255, a: 1.0 }); |
119 | m.insert("maroon" , Color { r: 128, g: 0, b: 0, a: 1.0 }); |
120 | m.insert("mediumaquamarine" , Color { r: 102, g: 205, b: 170, a: 1.0 }); |
121 | m.insert("mediumblue" , Color { r: 0, g: 0, b: 205, a: 1.0 }); |
122 | m.insert("mediumorchid" , Color { r: 186, g: 85, b: 211, a: 1.0 }); |
123 | m.insert("mediumpurple" , Color { r: 147, g: 112, b: 219, a: 1.0 }); |
124 | m.insert("mediumseagreen" , Color { r: 60, g: 179, b: 113, a: 1.0 }); |
125 | m.insert("mediumslateblue" , Color { r: 123, g: 104, b: 238, a: 1.0 }); |
126 | m.insert("mediumspringgreen" , Color { r: 0, g: 250, b: 154, a: 1.0 }); |
127 | m.insert("mediumturquoise" , Color { r: 72, g: 209, b: 204, a: 1.0 }); |
128 | m.insert("mediumvioletred" , Color { r: 199, g: 21, b: 133, a: 1.0 }); |
129 | m.insert("midnightblue" , Color { r: 25, g: 25, b: 112, a: 1.0 }); |
130 | m.insert("mintcream" , Color { r: 245, g: 255, b: 250, a: 1.0 }); |
131 | m.insert("mistyrose" , Color { r: 255, g: 228, b: 225, a: 1.0 }); |
132 | m.insert("moccasin" , Color { r: 255, g: 228, b: 181, a: 1.0 }); |
133 | m.insert("navajowhite" , Color { r: 255, g: 222, b: 173, a: 1.0 }); |
134 | m.insert("navy" , Color { r: 0, g: 0, b: 128, a: 1.0 }); |
135 | m.insert("oldlace" , Color { r: 253, g: 245, b: 230, a: 1.0 }); |
136 | m.insert("olive" , Color { r: 128, g: 128, b: 0, a: 1.0 }); |
137 | m.insert("olivedrab" , Color { r: 107, g: 142, b: 35, a: 1.0 }); |
138 | m.insert("orange" , Color { r: 255, g: 165, b: 0, a: 1.0 }); |
139 | m.insert("orangered" , Color { r: 255, g: 69, b: 0, a: 1.0 }); |
140 | m.insert("orchid" , Color { r: 218, g: 112, b: 214, a: 1.0 }); |
141 | m.insert("palegoldenrod" , Color { r: 238, g: 232, b: 170, a: 1.0 }); |
142 | m.insert("palegreen" , Color { r: 152, g: 251, b: 152, a: 1.0 }); |
143 | m.insert("paleturquoise" , Color { r: 175, g: 238, b: 238, a: 1.0 }); |
144 | m.insert("palevioletred" , Color { r: 219, g: 112, b: 147, a: 1.0 }); |
145 | m.insert("papayawhip" , Color { r: 255, g: 239, b: 213, a: 1.0 }); |
146 | m.insert("peachpuff" , Color { r: 255, g: 218, b: 185, a: 1.0 }); |
147 | m.insert("peru" , Color { r: 205, g: 133, b: 63, a: 1.0 }); |
148 | m.insert("pink" , Color { r: 255, g: 192, b: 203, a: 1.0 }); |
149 | m.insert("plum" , Color { r: 221, g: 160, b: 221, a: 1.0 }); |
150 | m.insert("powderblue" , Color { r: 176, g: 224, b: 230, a: 1.0 }); |
151 | m.insert("purple" , Color { r: 128, g: 0, b: 128, a: 1.0 }); |
152 | m.insert("red" , Color { r: 255, g: 0, b: 0, a: 1.0 }); |
153 | m.insert("rosybrown" , Color { r: 188, g: 143, b: 143, a: 1.0 }); |
154 | m.insert("royalblue" , Color { r: 65, g: 105, b: 225, a: 1.0 }); |
155 | m.insert("saddlebrown" , Color { r: 139, g: 69, b: 19, a: 1.0 }); |
156 | m.insert("salmon" , Color { r: 250, g: 128, b: 114, a: 1.0 }); |
157 | m.insert("sandybrown" , Color { r: 244, g: 164, b: 96, a: 1.0 }); |
158 | m.insert("seagreen" , Color { r: 46, g: 139, b: 87, a: 1.0 }); |
159 | m.insert("seashell" , Color { r: 255, g: 245, b: 238, a: 1.0 }); |
160 | m.insert("sienna" , Color { r: 160, g: 82, b: 45, a: 1.0 }); |
161 | m.insert("silver" , Color { r: 192, g: 192, b: 192, a: 1.0 }); |
162 | m.insert("skyblue" , Color { r: 135, g: 206, b: 235, a: 1.0 }); |
163 | m.insert("slateblue" , Color { r: 106, g: 90, b: 205, a: 1.0 }); |
164 | m.insert("slategray" , Color { r: 112, g: 128, b: 144, a: 1.0 }); |
165 | m.insert("slategrey" , Color { r: 112, g: 128, b: 144, a: 1.0 }); |
166 | m.insert("snow" , Color { r: 255, g: 250, b: 250, a: 1.0 }); |
167 | m.insert("springgreen" , Color { r: 0, g: 255, b: 127, a: 1.0 }); |
168 | m.insert("steelblue" , Color { r: 70, g: 130, b: 180, a: 1.0 }); |
169 | m.insert("tan" , Color { r: 210, g: 180, b: 140, a: 1.0 }); |
170 | m.insert("teal" , Color { r: 0, g: 128, b: 128, a: 1.0 }); |
171 | m.insert("thistle" , Color { r: 216, g: 191, b: 216, a: 1.0 }); |
172 | m.insert("tomato" , Color { r: 255, g: 99, b: 71, a: 1.0 }); |
173 | m.insert("turquoise" , Color { r: 64, g: 224, b: 208, a: 1.0 }); |
174 | m.insert("violet" , Color { r: 238, g: 130, b: 238, a: 1.0 }); |
175 | m.insert("wheat" , Color { r: 245, g: 222, b: 179, a: 1.0 }); |
176 | m.insert("white" , Color { r: 255, g: 255, b: 255, a: 1.0 }); |
177 | m.insert("whitesmoke" , Color { r: 245, g: 245, b: 245, a: 1.0 }); |
178 | m.insert("yellow" , Color { r: 255, g: 255, b: 0, a: 1.0 }); |
179 | m.insert("yellowgreen" , Color { r: 154, g: 205, b: 50, a: 1.0 }); |
180 | m |
181 | }; |
182 | } |
183 | |