1const SALTS: [u8; 142] = [
7 3, 8, 0, 5, 0, 0, 0, 0, 3, 0, 1, 0, 9, 0, 112, 7, 3, 0, 1, 19, 1, 0, 0, 0, 7, 3, 5, 2, 23, 38,
8 9, 0, 4, 28, 5, 3, 0, 0, 1, 0, 0, 18, 7, 0, 3, 2, 8, 2, 13, 16, 12, 1, 3, 0, 11, 0, 14, 0, 1,
9 0, 2, 4, 1, 0, 3, 6, 1, 0, 3, 3, 0, 0, 3, 0, 6, 17, 0, 10, 0, 0, 1, 1, 7, 12, 1, 7, 0, 2, 0, 0,
10 1, 1, 1, 2, 1, 0, 1, 0, 3, 6, 5, 1, 0, 1, 5, 0, 2, 0, 0, 1, 0, 1, 0, 1, 0, 1, 6, 6, 2, 2, 0, 5,
11 0, 0, 1, 4, 2, 0, 0, 2, 2, 0, 1, 0, 0, 1, 5, 0, 0, 1, 0, 0,
12];
13
14pub(crate) const NAMES: [&str; 142] = [
15 "rosybrown",
16 "forestgreen",
17 "cornsilk",
18 "silver",
19 "purple",
20 "thistle",
21 "antiquewhite",
22 "mediumspringgreen",
23 "dimgray",
24 "olivedrab",
25 "wheat",
26 "mediumturquoise",
27 "darkseagreen",
28 "burlywood",
29 "magenta",
30 "lemonchiffon",
31 "darkkhaki",
32 "lightyellow",
33 "mediumslateblue",
34 "mediumorchid",
35 "rebeccapurple",
36 "transparent",
37 "springgreen",
38 "maroon",
39 "lightseagreen",
40 "yellow",
41 "gray",
42 "tan",
43 "gainsboro",
44 "chartreuse",
45 "gold",
46 "orchid",
47 "red",
48 "snow",
49 "greenyellow",
50 "limegreen",
51 "aqua",
52 "salmon",
53 "sienna",
54 "slateblue",
55 "aquamarine",
56 "azure",
57 "saddlebrown",
58 "lightskyblue",
59 "cornflowerblue",
60 "darkorange",
61 "dodgerblue",
62 "midnightblue",
63 "mediumpurple",
64 "white",
65 "darkslateblue",
66 "darkturquoise",
67 "paleturquoise",
68 "linen",
69 "slategray",
70 "lightpink",
71 "lightcyan",
72 "peru",
73 "beige",
74 "indianred",
75 "navajowhite",
76 "green",
77 "lightblue",
78 "mediumaquamarine",
79 "palegreen",
80 "skyblue",
81 "darkviolet",
82 "deeppink",
83 "darkcyan",
84 "peachpuff",
85 "navy",
86 "darkolivegreen",
87 "lavender",
88 "lightgoldenrodyellow",
89 "moccasin",
90 "deepskyblue",
91 "firebrick",
92 "ghostwhite",
93 "honeydew",
94 "turquoise",
95 "darkorchid",
96 "plum",
97 "lightgray",
98 "chocolate",
99 "lightsteelblue",
100 "bisque",
101 "mediumblue",
102 "aliceblue",
103 "lightcoral",
104 "lightslategray",
105 "darkgreen",
106 "mintcream",
107 "coral",
108 "darkmagenta",
109 "mistyrose",
110 "whitesmoke",
111 "lightsalmon",
112 "mediumvioletred",
113 "tomato",
114 "indigo",
115 "brown",
116 "lawngreen",
117 "cadetblue",
118 "violet",
119 "fuchsia",
120 "darkblue",
121 "orange",
122 "mediumseagreen",
123 "lime",
124 "blue",
125 "darkred",
126 "blueviolet",
127 "papayawhip",
128 "blanchedalmond",
129 "seagreen",
130 "steelblue",
131 "seashell",
132 "lavenderblush",
133 "floralwhite",
134 "lightgreen",
135 "darksalmon",
136 "black",
137 "crimson",
138 "hotpink",
139 "darkslategray",
140 "palevioletred",
141 "oldlace",
142 "darkgray",
143 "olive",
144 "palegoldenrod",
145 "powderblue",
146 "pink",
147 "orangered",
148 "ivory",
149 "teal",
150 "cyan",
151 "darkgoldenrod",
152 "royalblue",
153 "sandybrown",
154 "khaki",
155 "goldenrod",
156 "yellowgreen",
157];
158
159pub(crate) const COLORS: [[u8; 4]; 142] = [
164 [188, 143, 143, 255],
165 [34, 139, 34, 255],
166 [255, 248, 220, 255],
167 [192, 192, 192, 255],
168 [128, 0, 128, 255],
169 [216, 191, 216, 255],
170 [250, 235, 215, 255],
171 [0, 250, 154, 255],
172 [105, 105, 105, 255],
173 [107, 142, 35, 255],
174 [245, 222, 179, 255],
175 [72, 209, 204, 255],
176 [143, 188, 143, 255],
177 [222, 184, 135, 255],
178 [255, 0, 255, 255],
179 [255, 250, 205, 255],
180 [189, 183, 107, 255],
181 [255, 255, 224, 255],
182 [123, 104, 238, 255],
183 [186, 85, 211, 255],
184 [102, 51, 153, 255],
185 [0, 0, 0, 0],
186 [0, 255, 127, 255],
187 [128, 0, 0, 255],
188 [32, 178, 170, 255],
189 [255, 255, 0, 255],
190 [128, 128, 128, 255],
191 [210, 180, 140, 255],
192 [220, 220, 220, 255],
193 [127, 255, 0, 255],
194 [255, 215, 0, 255],
195 [218, 112, 214, 255],
196 [255, 0, 0, 255],
197 [255, 250, 250, 255],
198 [173, 255, 47, 255],
199 [50, 205, 50, 255],
200 [0, 255, 255, 255],
201 [250, 128, 114, 255],
202 [160, 82, 45, 255],
203 [106, 90, 205, 255],
204 [127, 255, 212, 255],
205 [240, 255, 255, 255],
206 [139, 69, 19, 255],
207 [135, 206, 250, 255],
208 [100, 149, 237, 255],
209 [255, 140, 0, 255],
210 [30, 144, 255, 255],
211 [25, 25, 112, 255],
212 [147, 112, 219, 255],
213 [255, 255, 255, 255],
214 [72, 61, 139, 255],
215 [0, 206, 209, 255],
216 [175, 238, 238, 255],
217 [250, 240, 230, 255],
218 [112, 128, 144, 255],
219 [255, 182, 193, 255],
220 [224, 255, 255, 255],
221 [205, 133, 63, 255],
222 [245, 245, 220, 255],
223 [205, 92, 92, 255],
224 [255, 222, 173, 255],
225 [0, 128, 0, 255],
226 [173, 216, 230, 255],
227 [102, 205, 170, 255],
228 [152, 251, 152, 255],
229 [135, 206, 235, 255],
230 [148, 0, 211, 255],
231 [255, 20, 147, 255],
232 [0, 139, 139, 255],
233 [255, 218, 185, 255],
234 [0, 0, 128, 255],
235 [85, 107, 47, 255],
236 [230, 230, 250, 255],
237 [250, 250, 210, 255],
238 [255, 228, 181, 255],
239 [0, 191, 255, 255],
240 [178, 34, 34, 255],
241 [248, 248, 255, 255],
242 [240, 255, 240, 255],
243 [64, 224, 208, 255],
244 [153, 50, 204, 255],
245 [221, 160, 221, 255],
246 [211, 211, 211, 255],
247 [210, 105, 30, 255],
248 [176, 196, 222, 255],
249 [255, 228, 196, 255],
250 [0, 0, 205, 255],
251 [240, 248, 255, 255],
252 [240, 128, 128, 255],
253 [119, 136, 153, 255],
254 [0, 100, 0, 255],
255 [245, 255, 250, 255],
256 [255, 127, 80, 255],
257 [139, 0, 139, 255],
258 [255, 228, 225, 255],
259 [245, 245, 245, 255],
260 [255, 160, 122, 255],
261 [199, 21, 133, 255],
262 [255, 99, 71, 255],
263 [75, 0, 130, 255],
264 [165, 42, 42, 255],
265 [124, 252, 0, 255],
266 [95, 158, 160, 255],
267 [238, 130, 238, 255],
268 [255, 0, 255, 255],
269 [0, 0, 139, 255],
270 [255, 165, 0, 255],
271 [60, 179, 113, 255],
272 [0, 255, 0, 255],
273 [0, 0, 255, 255],
274 [139, 0, 0, 255],
275 [138, 43, 226, 255],
276 [255, 239, 213, 255],
277 [255, 235, 205, 255],
278 [46, 139, 87, 255],
279 [70, 130, 180, 255],
280 [255, 245, 238, 255],
281 [255, 240, 245, 255],
282 [255, 250, 240, 255],
283 [144, 238, 144, 255],
284 [233, 150, 122, 255],
285 [0, 0, 0, 255],
286 [220, 20, 60, 255],
287 [255, 105, 180, 255],
288 [47, 79, 79, 255],
289 [219, 112, 147, 255],
290 [253, 245, 230, 255],
291 [169, 169, 169, 255],
292 [128, 128, 0, 255],
293 [238, 232, 170, 255],
294 [176, 224, 230, 255],
295 [255, 192, 203, 255],
296 [255, 69, 0, 255],
297 [255, 255, 240, 255],
298 [0, 128, 128, 255],
299 [0, 255, 255, 255],
300 [184, 134, 11, 255],
301 [65, 105, 225, 255],
302 [244, 164, 96, 255],
303 [240, 230, 140, 255],
304 [218, 165, 32, 255],
305 [154, 205, 50, 255],
306];
307
308#[inline]
313fn weak_hash(key: u32, salt: u32, n: usize) -> usize {
314 let y = key.wrapping_add(salt).wrapping_mul(2654435769);
315 let y = y ^ key;
316 (((y as u64) * (n as u64)) >> 32) as usize
317}
318
319pub(crate) fn lookup_palette_index(s: &str) -> Option<usize> {
322 let mut key = 0_u32;
323 for b in s.as_bytes() {
324 key = key.wrapping_mul(9).wrapping_add(*b as u32);
325 }
326 let salt = SALTS[weak_hash(key, 0, SALTS.len())] as u32;
327 let ix = weak_hash(key, salt, SALTS.len());
328 if s == NAMES[ix] {
329 Some(ix)
330 } else {
331 None
332 }
333}