Coverage Report

Created: 2026-06-10 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tmux/colour.c
Line
Count
Source
1
/* $OpenBSD$ */
2
3
/*
4
 * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
5
 * Copyright (c) 2016 Avi Halachmi <avihpit@yahoo.com>
6
 *
7
 * Permission to use, copy, modify, and distribute this software for any
8
 * purpose with or without fee is hereby granted, provided that the above
9
 * copyright notice and this permission notice appear in all copies.
10
 *
11
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
16
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
17
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
 */
19
20
#include <sys/types.h>
21
22
#include <ctype.h>
23
#include <stdlib.h>
24
#include <string.h>
25
#include <math.h>
26
27
#include "tmux.h"
28
29
static int
30
colour_dist_sq(int R, int G, int B, int r, int g, int b)
31
0
{
32
0
  return ((R - r) * (R - r) + (G - g) * (G - g) + (B - b) * (B - b));
33
0
}
34
35
static int
36
colour_to_6cube(int v)
37
0
{
38
0
  if (v < 48)
39
0
    return (0);
40
0
  if (v < 114)
41
0
    return (1);
42
0
  return ((v - 35) / 40);
43
0
}
44
45
/*
46
 * Convert an RGB triplet to the xterm(1) 256 colour palette.
47
 *
48
 * xterm provides a 6x6x6 colour cube (16 - 231) and 24 greys (232 - 255). We
49
 * map our RGB colour to the closest in the cube, also work out the closest
50
 * grey, and use the nearest of the two.
51
 *
52
 * Note that the xterm has much lower resolution for darker colours (they are
53
 * not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f
54
 * (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more
55
 * evenly spread (8, 18, 28 ... 238).
56
 */
57
int
58
colour_find_rgb(u_char r, u_char g, u_char b)
59
0
{
60
0
  static const int  q2c[6] = { 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff };
61
0
  int     qr, qg, qb, cr, cg, cb, d, idx;
62
0
  int     grey_avg, grey_idx, grey;
63
64
  /* Map RGB to 6x6x6 cube. */
65
0
  qr = colour_to_6cube(r); cr = q2c[qr];
66
0
  qg = colour_to_6cube(g); cg = q2c[qg];
67
0
  qb = colour_to_6cube(b); cb = q2c[qb];
68
69
  /* If we have hit the colour exactly, return early. */
70
0
  if (cr == r && cg == g && cb == b)
71
0
    return ((16 + (36 * qr) + (6 * qg) + qb) | COLOUR_FLAG_256);
72
73
  /* Work out the closest grey (average of RGB). */
74
0
  grey_avg = (r + g + b) / 3;
75
0
  if (grey_avg > 238)
76
0
    grey_idx = 23;
77
0
  else
78
0
    grey_idx = (grey_avg - 3) / 10;
79
0
  grey = 8 + (10 * grey_idx);
80
81
  /* Is grey or 6x6x6 colour closest? */
82
0
  d = colour_dist_sq(cr, cg, cb, r, g, b);
83
0
  if (colour_dist_sq(grey, grey, grey, r, g, b) < d)
84
0
    idx = 232 + grey_idx;
85
0
  else
86
0
    idx = 16 + (36 * qr) + (6 * qg) + qb;
87
0
  return (idx | COLOUR_FLAG_256);
88
0
}
89
90
/* Join RGB into a colour. */
91
int
92
colour_join_rgb(u_char r, u_char g, u_char b)
93
504
{
94
504
  return ((((int)((r) & 0xff)) << 16) |
95
504
      (((int)((g) & 0xff)) << 8) |
96
504
      (((int)((b) & 0xff))) | COLOUR_FLAG_RGB);
97
504
}
98
99
/* Split colour into RGB. */
100
void
101
colour_split_rgb(int c, u_char *r, u_char *g, u_char *b)
102
0
{
103
0
  *r = (c >> 16) & 0xff;
104
0
  *g = (c >> 8) & 0xff;
105
0
  *b = c & 0xff;
106
0
}
107
108
/* Force colour to RGB if not already. */
109
int
110
colour_force_rgb(int c)
111
18.1k
{
112
18.1k
  if (c & COLOUR_FLAG_RGB)
113
1.06k
    return (c);
114
17.1k
  if (c & COLOUR_FLAG_256)
115
671
    return (colour_256toRGB(c));
116
16.4k
  if (c >= 0 && c <= 7)
117
9.30k
    return (colour_256toRGB(c));
118
7.13k
  if (c >= 90 && c <= 97)
119
6.73k
    return (colour_256toRGB(8 + c - 90));
120
400
  return (-1);
121
7.13k
}
122
123
/* Convert colour to a string. */
124
const char *
125
colour_tostring(int c)
126
880
{
127
880
  static char s[32];
128
880
  u_char    r, g, b;
129
130
880
  if (c == -1)
131
255
    return ("none");
132
133
625
  if (c & COLOUR_FLAG_RGB) {
134
0
    colour_split_rgb(c, &r, &g, &b);
135
0
    xsnprintf(s, sizeof s, "#%02x%02x%02x", r, g, b);
136
0
    return (s);
137
0
  }
138
139
625
  if (c & COLOUR_FLAG_256) {
140
0
    xsnprintf(s, sizeof s, "colour%u", c & 0xff);
141
0
    return (s);
142
0
  }
143
144
625
  switch (c) {
145
0
  case 0:
146
0
    return ("black");
147
227
  case 1:
148
227
    return ("red");
149
0
  case 2:
150
0
    return ("green");
151
0
  case 3:
152
0
    return ("yellow");
153
200
  case 4:
154
200
    return ("blue");
155
0
  case 5:
156
0
    return ("magenta");
157
0
  case 6:
158
0
    return ("cyan");
159
0
  case 7:
160
0
    return ("white");
161
198
  case 8:
162
198
    return ("default");
163
0
  case 9:
164
0
    return ("terminal");
165
0
  case 90:
166
0
    return ("brightblack");
167
0
  case 91:
168
0
    return ("brightred");
169
0
  case 92:
170
0
    return ("brightgreen");
171
0
  case 93:
172
0
    return ("brightyellow");
173
0
  case 94:
174
0
    return ("brightblue");
175
0
  case 95:
176
0
    return ("brightmagenta");
177
0
  case 96:
178
0
    return ("brightcyan");
179
0
  case 97:
180
0
    return ("brightwhite");
181
625
  }
182
0
  return ("invalid");
183
625
}
184
185
/* Convert background colour to theme. */
186
enum client_theme
187
colour_totheme(int c)
188
0
{
189
0
  int r, g, b, brightness;
190
191
0
  if (c == -1)
192
0
    return (THEME_UNKNOWN);
193
194
0
  if (c & COLOUR_FLAG_RGB) {
195
0
    r = (c >> 16) & 0xff;
196
0
    g = (c >> 8) & 0xff;
197
0
    b = (c >> 0) & 0xff;
198
199
0
    brightness = r + g + b;
200
0
    if (brightness > 382)
201
0
      return (THEME_LIGHT);
202
0
    return (THEME_DARK);
203
0
  }
204
205
0
  if (c & COLOUR_FLAG_256)
206
0
    return (colour_totheme(colour_256toRGB(c)));
207
208
0
  switch (c) {
209
0
  case 0:
210
0
  case 90:
211
0
    return (THEME_DARK);
212
0
  case 7:
213
0
  case 97:
214
0
    return (THEME_LIGHT);
215
0
  default:
216
0
    if (c >= 0 && c <= 7)
217
0
      return (colour_totheme(colour_256toRGB(c)));
218
0
    if (c >= 90 && c <= 97)
219
0
      return (colour_totheme(colour_256toRGB(8 + c - 90)));
220
0
    break;
221
0
  }
222
0
  return (THEME_UNKNOWN);
223
0
}
224
225
/* Convert colour from string. */
226
int
227
colour_fromstring(const char *s)
228
28.1k
{
229
28.1k
  const char  *errstr;
230
28.1k
  const char  *cp;
231
28.1k
  int    n;
232
28.1k
  u_char     r, g, b;
233
234
28.1k
  if (*s == '#' && strlen(s) == 7) {
235
2.05k
    for (cp = s + 1; isxdigit((u_char) *cp); cp++)
236
2.05k
      ;
237
488
    if (*cp != '\0')
238
266
      return (-1);
239
222
    n = sscanf(s + 1, "%2hhx%2hhx%2hhx", &r, &g, &b);
240
222
    if (n != 3)
241
0
      return (-1);
242
222
    return (colour_join_rgb(r, g, b));
243
222
  }
244
245
27.6k
  if (strncasecmp(s, "colour", (sizeof "colour") - 1) == 0) {
246
304
    n = strtonum(s + (sizeof "colour") - 1, 0, 255, &errstr);
247
304
    if (errstr != NULL)
248
101
      return (-1);
249
203
    return (n | COLOUR_FLAG_256);
250
304
  }
251
27.3k
  if (strncasecmp(s, "color", (sizeof "color") - 1) == 0) {
252
1.30k
    n = strtonum(s + (sizeof "color") - 1, 0, 255, &errstr);
253
1.30k
    if (errstr != NULL)
254
838
      return (-1);
255
468
    return (n | COLOUR_FLAG_256);
256
1.30k
  }
257
258
26.0k
  if (strcasecmp(s, "default") == 0)
259
200
    return (8);
260
25.8k
  if (strcasecmp(s, "terminal") == 0)
261
200
    return (9);
262
263
25.6k
  if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0)
264
964
    return (0);
265
24.6k
  if (strcasecmp(s, "red") == 0 || strcmp(s, "1") == 0)
266
1.07k
    return (1);
267
23.6k
  if (strcasecmp(s, "green") == 0 || strcmp(s, "2") == 0)
268
2.23k
    return (2);
269
21.3k
  if (strcasecmp(s, "yellow") == 0 || strcmp(s, "3") == 0)
270
1.16k
    return (3);
271
20.2k
  if (strcasecmp(s, "blue") == 0 || strcmp(s, "4") == 0)
272
830
    return (4);
273
19.3k
  if (strcasecmp(s, "magenta") == 0 || strcmp(s, "5") == 0)
274
1.26k
    return (5);
275
18.1k
  if (strcasecmp(s, "cyan") == 0 || strcmp(s, "6") == 0)
276
1.16k
    return (6);
277
16.9k
  if (strcasecmp(s, "white") == 0 || strcmp(s, "7") == 0)
278
606
    return (7);
279
16.3k
  if (strcasecmp(s, "brightblack") == 0 || strcmp(s, "90") == 0)
280
2.69k
    return (90);
281
13.6k
  if (strcasecmp(s, "brightred") == 0 || strcmp(s, "91") == 0)
282
475
    return (91);
283
13.1k
  if (strcasecmp(s, "brightgreen") == 0 || strcmp(s, "92") == 0)
284
821
    return (92);
285
12.3k
  if (strcasecmp(s, "brightyellow") == 0 || strcmp(s, "93") == 0)
286
406
    return (93);
287
11.9k
  if (strcasecmp(s, "brightblue") == 0 || strcmp(s, "94") == 0)
288
787
    return (94);
289
11.1k
  if (strcasecmp(s, "brightmagenta") == 0 || strcmp(s, "95") == 0)
290
556
    return (95);
291
10.6k
  if (strcasecmp(s, "brightcyan") == 0 || strcmp(s, "96") == 0)
292
468
    return (96);
293
10.1k
  if (strcasecmp(s, "brightwhite") == 0 || strcmp(s, "97") == 0)
294
533
    return (97);
295
9.60k
  return (colour_byname(s));
296
10.1k
}
297
298
/* Convert 256 colour to RGB colour. */
299
int
300
colour_256toRGB(int c)
301
16.7k
{
302
16.7k
  static const int table[256] = {
303
16.7k
    0x000000, 0x800000, 0x008000, 0x808000,
304
16.7k
    0x000080, 0x800080, 0x008080, 0xc0c0c0,
305
16.7k
    0x808080, 0xff0000, 0x00ff00, 0xffff00,
306
16.7k
    0x0000ff, 0xff00ff, 0x00ffff, 0xffffff,
307
16.7k
    0x000000, 0x00005f, 0x000087, 0x0000af,
308
16.7k
    0x0000d7, 0x0000ff, 0x005f00, 0x005f5f,
309
16.7k
    0x005f87, 0x005faf, 0x005fd7, 0x005fff,
310
16.7k
    0x008700, 0x00875f, 0x008787, 0x0087af,
311
16.7k
    0x0087d7, 0x0087ff, 0x00af00, 0x00af5f,
312
16.7k
    0x00af87, 0x00afaf, 0x00afd7, 0x00afff,
313
16.7k
    0x00d700, 0x00d75f, 0x00d787, 0x00d7af,
314
16.7k
    0x00d7d7, 0x00d7ff, 0x00ff00, 0x00ff5f,
315
16.7k
    0x00ff87, 0x00ffaf, 0x00ffd7, 0x00ffff,
316
16.7k
    0x5f0000, 0x5f005f, 0x5f0087, 0x5f00af,
317
16.7k
    0x5f00d7, 0x5f00ff, 0x5f5f00, 0x5f5f5f,
318
16.7k
    0x5f5f87, 0x5f5faf, 0x5f5fd7, 0x5f5fff,
319
16.7k
    0x5f8700, 0x5f875f, 0x5f8787, 0x5f87af,
320
16.7k
    0x5f87d7, 0x5f87ff, 0x5faf00, 0x5faf5f,
321
16.7k
    0x5faf87, 0x5fafaf, 0x5fafd7, 0x5fafff,
322
16.7k
    0x5fd700, 0x5fd75f, 0x5fd787, 0x5fd7af,
323
16.7k
    0x5fd7d7, 0x5fd7ff, 0x5fff00, 0x5fff5f,
324
16.7k
    0x5fff87, 0x5fffaf, 0x5fffd7, 0x5fffff,
325
16.7k
    0x870000, 0x87005f, 0x870087, 0x8700af,
326
16.7k
    0x8700d7, 0x8700ff, 0x875f00, 0x875f5f,
327
16.7k
    0x875f87, 0x875faf, 0x875fd7, 0x875fff,
328
16.7k
    0x878700, 0x87875f, 0x878787, 0x8787af,
329
16.7k
    0x8787d7, 0x8787ff, 0x87af00, 0x87af5f,
330
16.7k
    0x87af87, 0x87afaf, 0x87afd7, 0x87afff,
331
16.7k
    0x87d700, 0x87d75f, 0x87d787, 0x87d7af,
332
16.7k
    0x87d7d7, 0x87d7ff, 0x87ff00, 0x87ff5f,
333
16.7k
    0x87ff87, 0x87ffaf, 0x87ffd7, 0x87ffff,
334
16.7k
    0xaf0000, 0xaf005f, 0xaf0087, 0xaf00af,
335
16.7k
    0xaf00d7, 0xaf00ff, 0xaf5f00, 0xaf5f5f,
336
16.7k
    0xaf5f87, 0xaf5faf, 0xaf5fd7, 0xaf5fff,
337
16.7k
    0xaf8700, 0xaf875f, 0xaf8787, 0xaf87af,
338
16.7k
    0xaf87d7, 0xaf87ff, 0xafaf00, 0xafaf5f,
339
16.7k
    0xafaf87, 0xafafaf, 0xafafd7, 0xafafff,
340
16.7k
    0xafd700, 0xafd75f, 0xafd787, 0xafd7af,
341
16.7k
    0xafd7d7, 0xafd7ff, 0xafff00, 0xafff5f,
342
16.7k
    0xafff87, 0xafffaf, 0xafffd7, 0xafffff,
343
16.7k
    0xd70000, 0xd7005f, 0xd70087, 0xd700af,
344
16.7k
    0xd700d7, 0xd700ff, 0xd75f00, 0xd75f5f,
345
16.7k
    0xd75f87, 0xd75faf, 0xd75fd7, 0xd75fff,
346
16.7k
    0xd78700, 0xd7875f, 0xd78787, 0xd787af,
347
16.7k
    0xd787d7, 0xd787ff, 0xd7af00, 0xd7af5f,
348
16.7k
    0xd7af87, 0xd7afaf, 0xd7afd7, 0xd7afff,
349
16.7k
    0xd7d700, 0xd7d75f, 0xd7d787, 0xd7d7af,
350
16.7k
    0xd7d7d7, 0xd7d7ff, 0xd7ff00, 0xd7ff5f,
351
16.7k
    0xd7ff87, 0xd7ffaf, 0xd7ffd7, 0xd7ffff,
352
16.7k
    0xff0000, 0xff005f, 0xff0087, 0xff00af,
353
16.7k
    0xff00d7, 0xff00ff, 0xff5f00, 0xff5f5f,
354
16.7k
    0xff5f87, 0xff5faf, 0xff5fd7, 0xff5fff,
355
16.7k
    0xff8700, 0xff875f, 0xff8787, 0xff87af,
356
16.7k
    0xff87d7, 0xff87ff, 0xffaf00, 0xffaf5f,
357
16.7k
    0xffaf87, 0xffafaf, 0xffafd7, 0xffafff,
358
16.7k
    0xffd700, 0xffd75f, 0xffd787, 0xffd7af,
359
16.7k
    0xffd7d7, 0xffd7ff, 0xffff00, 0xffff5f,
360
16.7k
    0xffff87, 0xffffaf, 0xffffd7, 0xffffff,
361
16.7k
    0x080808, 0x121212, 0x1c1c1c, 0x262626,
362
16.7k
    0x303030, 0x3a3a3a, 0x444444, 0x4e4e4e,
363
16.7k
    0x585858, 0x626262, 0x6c6c6c, 0x767676,
364
16.7k
    0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e,
365
16.7k
    0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6,
366
16.7k
    0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee
367
16.7k
  };
368
369
16.7k
  return (table[c & 0xff] | COLOUR_FLAG_RGB);
370
16.7k
}
371
372
/* Convert 256 colour to 16 colour. */
373
int
374
colour_256to16(int c)
375
0
{
376
0
  static const char table[256] = {
377
0
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
378
0
     0,  4,  4,  4, 12, 12,  2,  6,  4,  4, 12, 12,  2,  2,  6,  4,
379
0
    12, 12,  2,  2,  2,  6, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10,
380
0
    10, 10, 10, 14,  1,  5,  4,  4, 12, 12,  3,  8,  4,  4, 12, 12,
381
0
     2,  2,  6,  4, 12, 12,  2,  2,  2,  6, 12, 12, 10, 10, 10, 10,
382
0
    14, 12, 10, 10, 10, 10, 10, 14,  1,  1,  5,  4, 12, 12,  1,  1,
383
0
     5,  4, 12, 12,  3,  3,  8,  4, 12, 12,  2,  2,  2,  6, 12, 12,
384
0
    10, 10, 10, 10, 14, 12, 10, 10, 10, 10, 10, 14,  1,  1,  1,  5,
385
0
    12, 12,  1,  1,  1,  5, 12, 12,  1,  1,  1,  5, 12, 12,  3,  3,
386
0
     3,  7, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10, 10, 10, 10, 14,
387
0
     9,  9,  9,  9, 13, 12,  9,  9,  9,  9, 13, 12,  9,  9,  9,  9,
388
0
    13, 12,  9,  9,  9,  9, 13, 12, 11, 11, 11, 11,  7, 12, 10, 10,
389
0
    10, 10, 10, 14,  9,  9,  9,  9,  9, 13,  9,  9,  9,  9,  9, 13,
390
0
     9,  9,  9,  9,  9, 13,  9,  9,  9,  9,  9, 13,  9,  9,  9,  9,
391
0
     9, 13, 11, 11, 11, 11, 11, 15,  0,  0,  0,  0,  0,  0,  8,  8,
392
0
     8,  8,  8,  8,  7,  7,  7,  7,  7,  7, 15, 15, 15, 15, 15, 15
393
0
  };
394
395
0
  return (table[c & 0xff]);
396
0
}
397
398
/* Get colour by X11 colour name. */
399
int
400
colour_byname(const char *name)
401
9.60k
{
402
9.60k
  static const struct {
403
9.60k
    const char  *name;
404
9.60k
    int    c;
405
9.60k
  } colours[] = {
406
9.60k
    { "AliceBlue", 0xf0f8ff },
407
9.60k
    { "AntiqueWhite", 0xfaebd7 },
408
9.60k
    { "AntiqueWhite1", 0xffefdb },
409
9.60k
    { "AntiqueWhite2", 0xeedfcc },
410
9.60k
    { "AntiqueWhite3", 0xcdc0b0 },
411
9.60k
    { "AntiqueWhite4", 0x8b8378 },
412
9.60k
    { "BlanchedAlmond", 0xffebcd },
413
9.60k
    { "BlueViolet", 0x8a2be2 },
414
9.60k
    { "CadetBlue", 0x5f9ea0 },
415
9.60k
    { "CadetBlue1", 0x98f5ff },
416
9.60k
    { "CadetBlue2", 0x8ee5ee },
417
9.60k
    { "CadetBlue3", 0x7ac5cd },
418
9.60k
    { "CadetBlue4", 0x53868b },
419
9.60k
    { "CornflowerBlue", 0x6495ed },
420
9.60k
    { "DarkBlue", 0x00008b },
421
9.60k
    { "DarkCyan", 0x008b8b },
422
9.60k
    { "DarkGoldenrod", 0xb8860b },
423
9.60k
    { "DarkGoldenrod1", 0xffb90f },
424
9.60k
    { "DarkGoldenrod2", 0xeead0e },
425
9.60k
    { "DarkGoldenrod3", 0xcd950c },
426
9.60k
    { "DarkGoldenrod4", 0x8b6508 },
427
9.60k
    { "DarkGray", 0xa9a9a9 },
428
9.60k
    { "DarkGreen", 0x006400 },
429
9.60k
    { "DarkGrey", 0xa9a9a9 },
430
9.60k
    { "DarkKhaki", 0xbdb76b },
431
9.60k
    { "DarkMagenta", 0x8b008b },
432
9.60k
    { "DarkOliveGreen", 0x556b2f },
433
9.60k
    { "DarkOliveGreen1", 0xcaff70 },
434
9.60k
    { "DarkOliveGreen2", 0xbcee68 },
435
9.60k
    { "DarkOliveGreen3", 0xa2cd5a },
436
9.60k
    { "DarkOliveGreen4", 0x6e8b3d },
437
9.60k
    { "DarkOrange", 0xff8c00 },
438
9.60k
    { "DarkOrange1", 0xff7f00 },
439
9.60k
    { "DarkOrange2", 0xee7600 },
440
9.60k
    { "DarkOrange3", 0xcd6600 },
441
9.60k
    { "DarkOrange4", 0x8b4500 },
442
9.60k
    { "DarkOrchid", 0x9932cc },
443
9.60k
    { "DarkOrchid1", 0xbf3eff },
444
9.60k
    { "DarkOrchid2", 0xb23aee },
445
9.60k
    { "DarkOrchid3", 0x9a32cd },
446
9.60k
    { "DarkOrchid4", 0x68228b },
447
9.60k
    { "DarkRed", 0x8b0000 },
448
9.60k
    { "DarkSalmon", 0xe9967a },
449
9.60k
    { "DarkSeaGreen", 0x8fbc8f },
450
9.60k
    { "DarkSeaGreen1", 0xc1ffc1 },
451
9.60k
    { "DarkSeaGreen2", 0xb4eeb4 },
452
9.60k
    { "DarkSeaGreen3", 0x9bcd9b },
453
9.60k
    { "DarkSeaGreen4", 0x698b69 },
454
9.60k
    { "DarkSlateBlue", 0x483d8b },
455
9.60k
    { "DarkSlateGray", 0x2f4f4f },
456
9.60k
    { "DarkSlateGray1", 0x97ffff },
457
9.60k
    { "DarkSlateGray2", 0x8deeee },
458
9.60k
    { "DarkSlateGray3", 0x79cdcd },
459
9.60k
    { "DarkSlateGray4", 0x528b8b },
460
9.60k
    { "DarkSlateGrey", 0x2f4f4f },
461
9.60k
    { "DarkTurquoise", 0x00ced1 },
462
9.60k
    { "DarkViolet", 0x9400d3 },
463
9.60k
    { "DeepPink", 0xff1493 },
464
9.60k
    { "DeepPink1", 0xff1493 },
465
9.60k
    { "DeepPink2", 0xee1289 },
466
9.60k
    { "DeepPink3", 0xcd1076 },
467
9.60k
    { "DeepPink4", 0x8b0a50 },
468
9.60k
    { "DeepSkyBlue", 0x00bfff },
469
9.60k
    { "DeepSkyBlue1", 0x00bfff },
470
9.60k
    { "DeepSkyBlue2", 0x00b2ee },
471
9.60k
    { "DeepSkyBlue3", 0x009acd },
472
9.60k
    { "DeepSkyBlue4", 0x00688b },
473
9.60k
    { "DimGray", 0x696969 },
474
9.60k
    { "DimGrey", 0x696969 },
475
9.60k
    { "DodgerBlue", 0x1e90ff },
476
9.60k
    { "DodgerBlue1", 0x1e90ff },
477
9.60k
    { "DodgerBlue2", 0x1c86ee },
478
9.60k
    { "DodgerBlue3", 0x1874cd },
479
9.60k
    { "DodgerBlue4", 0x104e8b },
480
9.60k
    { "FloralWhite", 0xfffaf0 },
481
9.60k
    { "ForestGreen", 0x228b22 },
482
9.60k
    { "GhostWhite", 0xf8f8ff },
483
9.60k
    { "GreenYellow", 0xadff2f },
484
9.60k
    { "HotPink", 0xff69b4 },
485
9.60k
    { "HotPink1", 0xff6eb4 },
486
9.60k
    { "HotPink2", 0xee6aa7 },
487
9.60k
    { "HotPink3", 0xcd6090 },
488
9.60k
    { "HotPink4", 0x8b3a62 },
489
9.60k
    { "IndianRed", 0xcd5c5c },
490
9.60k
    { "IndianRed1", 0xff6a6a },
491
9.60k
    { "IndianRed2", 0xee6363 },
492
9.60k
    { "IndianRed3", 0xcd5555 },
493
9.60k
    { "IndianRed4", 0x8b3a3a },
494
9.60k
    { "LavenderBlush", 0xfff0f5 },
495
9.60k
    { "LavenderBlush1", 0xfff0f5 },
496
9.60k
    { "LavenderBlush2", 0xeee0e5 },
497
9.60k
    { "LavenderBlush3", 0xcdc1c5 },
498
9.60k
    { "LavenderBlush4", 0x8b8386 },
499
9.60k
    { "LawnGreen", 0x7cfc00 },
500
9.60k
    { "LemonChiffon", 0xfffacd },
501
9.60k
    { "LemonChiffon1", 0xfffacd },
502
9.60k
    { "LemonChiffon2", 0xeee9bf },
503
9.60k
    { "LemonChiffon3", 0xcdc9a5 },
504
9.60k
    { "LemonChiffon4", 0x8b8970 },
505
9.60k
    { "LightBlue", 0xadd8e6 },
506
9.60k
    { "LightBlue1", 0xbfefff },
507
9.60k
    { "LightBlue2", 0xb2dfee },
508
9.60k
    { "LightBlue3", 0x9ac0cd },
509
9.60k
    { "LightBlue4", 0x68838b },
510
9.60k
    { "LightCoral", 0xf08080 },
511
9.60k
    { "LightCyan", 0xe0ffff },
512
9.60k
    { "LightCyan1", 0xe0ffff },
513
9.60k
    { "LightCyan2", 0xd1eeee },
514
9.60k
    { "LightCyan3", 0xb4cdcd },
515
9.60k
    { "LightCyan4", 0x7a8b8b },
516
9.60k
    { "LightGoldenrod", 0xeedd82 },
517
9.60k
    { "LightGoldenrod1", 0xffec8b },
518
9.60k
    { "LightGoldenrod2", 0xeedc82 },
519
9.60k
    { "LightGoldenrod3", 0xcdbe70 },
520
9.60k
    { "LightGoldenrod4", 0x8b814c },
521
9.60k
    { "LightGoldenrodYellow", 0xfafad2 },
522
9.60k
    { "LightGray", 0xd3d3d3 },
523
9.60k
    { "LightGreen", 0x90ee90 },
524
9.60k
    { "LightGrey", 0xd3d3d3 },
525
9.60k
    { "LightPink", 0xffb6c1 },
526
9.60k
    { "LightPink1", 0xffaeb9 },
527
9.60k
    { "LightPink2", 0xeea2ad },
528
9.60k
    { "LightPink3", 0xcd8c95 },
529
9.60k
    { "LightPink4", 0x8b5f65 },
530
9.60k
    { "LightSalmon", 0xffa07a },
531
9.60k
    { "LightSalmon1", 0xffa07a },
532
9.60k
    { "LightSalmon2", 0xee9572 },
533
9.60k
    { "LightSalmon3", 0xcd8162 },
534
9.60k
    { "LightSalmon4", 0x8b5742 },
535
9.60k
    { "LightSeaGreen", 0x20b2aa },
536
9.60k
    { "LightSkyBlue", 0x87cefa },
537
9.60k
    { "LightSkyBlue1", 0xb0e2ff },
538
9.60k
    { "LightSkyBlue2", 0xa4d3ee },
539
9.60k
    { "LightSkyBlue3", 0x8db6cd },
540
9.60k
    { "LightSkyBlue4", 0x607b8b },
541
9.60k
    { "LightSlateBlue", 0x8470ff },
542
9.60k
    { "LightSlateGray", 0x778899 },
543
9.60k
    { "LightSlateGrey", 0x778899 },
544
9.60k
    { "LightSteelBlue", 0xb0c4de },
545
9.60k
    { "LightSteelBlue1", 0xcae1ff },
546
9.60k
    { "LightSteelBlue2", 0xbcd2ee },
547
9.60k
    { "LightSteelBlue3", 0xa2b5cd },
548
9.60k
    { "LightSteelBlue4", 0x6e7b8b },
549
9.60k
    { "LightYellow", 0xffffe0 },
550
9.60k
    { "LightYellow1", 0xffffe0 },
551
9.60k
    { "LightYellow2", 0xeeeed1 },
552
9.60k
    { "LightYellow3", 0xcdcdb4 },
553
9.60k
    { "LightYellow4", 0x8b8b7a },
554
9.60k
    { "LimeGreen", 0x32cd32 },
555
9.60k
    { "MediumAquamarine", 0x66cdaa },
556
9.60k
    { "MediumBlue", 0x0000cd },
557
9.60k
    { "MediumOrchid", 0xba55d3 },
558
9.60k
    { "MediumOrchid1", 0xe066ff },
559
9.60k
    { "MediumOrchid2", 0xd15fee },
560
9.60k
    { "MediumOrchid3", 0xb452cd },
561
9.60k
    { "MediumOrchid4", 0x7a378b },
562
9.60k
    { "MediumPurple", 0x9370db },
563
9.60k
    { "MediumPurple1", 0xab82ff },
564
9.60k
    { "MediumPurple2", 0x9f79ee },
565
9.60k
    { "MediumPurple3", 0x8968cd },
566
9.60k
    { "MediumPurple4", 0x5d478b },
567
9.60k
    { "MediumSeaGreen", 0x3cb371 },
568
9.60k
    { "MediumSlateBlue", 0x7b68ee },
569
9.60k
    { "MediumSpringGreen", 0x00fa9a },
570
9.60k
    { "MediumTurquoise", 0x48d1cc },
571
9.60k
    { "MediumVioletRed", 0xc71585 },
572
9.60k
    { "MidnightBlue", 0x191970 },
573
9.60k
    { "MintCream", 0xf5fffa },
574
9.60k
    { "MistyRose", 0xffe4e1 },
575
9.60k
    { "MistyRose1", 0xffe4e1 },
576
9.60k
    { "MistyRose2", 0xeed5d2 },
577
9.60k
    { "MistyRose3", 0xcdb7b5 },
578
9.60k
    { "MistyRose4", 0x8b7d7b },
579
9.60k
    { "NavajoWhite", 0xffdead },
580
9.60k
    { "NavajoWhite1", 0xffdead },
581
9.60k
    { "NavajoWhite2", 0xeecfa1 },
582
9.60k
    { "NavajoWhite3", 0xcdb38b },
583
9.60k
    { "NavajoWhite4", 0x8b795e },
584
9.60k
    { "NavyBlue", 0x000080 },
585
9.60k
    { "OldLace", 0xfdf5e6 },
586
9.60k
    { "OliveDrab", 0x6b8e23 },
587
9.60k
    { "OliveDrab1", 0xc0ff3e },
588
9.60k
    { "OliveDrab2", 0xb3ee3a },
589
9.60k
    { "OliveDrab3", 0x9acd32 },
590
9.60k
    { "OliveDrab4", 0x698b22 },
591
9.60k
    { "OrangeRed", 0xff4500 },
592
9.60k
    { "OrangeRed1", 0xff4500 },
593
9.60k
    { "OrangeRed2", 0xee4000 },
594
9.60k
    { "OrangeRed3", 0xcd3700 },
595
9.60k
    { "OrangeRed4", 0x8b2500 },
596
9.60k
    { "PaleGoldenrod", 0xeee8aa },
597
9.60k
    { "PaleGreen", 0x98fb98 },
598
9.60k
    { "PaleGreen1", 0x9aff9a },
599
9.60k
    { "PaleGreen2", 0x90ee90 },
600
9.60k
    { "PaleGreen3", 0x7ccd7c },
601
9.60k
    { "PaleGreen4", 0x548b54 },
602
9.60k
    { "PaleTurquoise", 0xafeeee },
603
9.60k
    { "PaleTurquoise1", 0xbbffff },
604
9.60k
    { "PaleTurquoise2", 0xaeeeee },
605
9.60k
    { "PaleTurquoise3", 0x96cdcd },
606
9.60k
    { "PaleTurquoise4", 0x668b8b },
607
9.60k
    { "PaleVioletRed", 0xdb7093 },
608
9.60k
    { "PaleVioletRed1", 0xff82ab },
609
9.60k
    { "PaleVioletRed2", 0xee799f },
610
9.60k
    { "PaleVioletRed3", 0xcd6889 },
611
9.60k
    { "PaleVioletRed4", 0x8b475d },
612
9.60k
    { "PapayaWhip", 0xffefd5 },
613
9.60k
    { "PeachPuff", 0xffdab9 },
614
9.60k
    { "PeachPuff1", 0xffdab9 },
615
9.60k
    { "PeachPuff2", 0xeecbad },
616
9.60k
    { "PeachPuff3", 0xcdaf95 },
617
9.60k
    { "PeachPuff4", 0x8b7765 },
618
9.60k
    { "PowderBlue", 0xb0e0e6 },
619
9.60k
    { "RebeccaPurple", 0x663399 },
620
9.60k
    { "RosyBrown", 0xbc8f8f },
621
9.60k
    { "RosyBrown1", 0xffc1c1 },
622
9.60k
    { "RosyBrown2", 0xeeb4b4 },
623
9.60k
    { "RosyBrown3", 0xcd9b9b },
624
9.60k
    { "RosyBrown4", 0x8b6969 },
625
9.60k
    { "RoyalBlue", 0x4169e1 },
626
9.60k
    { "RoyalBlue1", 0x4876ff },
627
9.60k
    { "RoyalBlue2", 0x436eee },
628
9.60k
    { "RoyalBlue3", 0x3a5fcd },
629
9.60k
    { "RoyalBlue4", 0x27408b },
630
9.60k
    { "SaddleBrown", 0x8b4513 },
631
9.60k
    { "SandyBrown", 0xf4a460 },
632
9.60k
    { "SeaGreen", 0x2e8b57 },
633
9.60k
    { "SeaGreen1", 0x54ff9f },
634
9.60k
    { "SeaGreen2", 0x4eee94 },
635
9.60k
    { "SeaGreen3", 0x43cd80 },
636
9.60k
    { "SeaGreen4", 0x2e8b57 },
637
9.60k
    { "SkyBlue", 0x87ceeb },
638
9.60k
    { "SkyBlue1", 0x87ceff },
639
9.60k
    { "SkyBlue2", 0x7ec0ee },
640
9.60k
    { "SkyBlue3", 0x6ca6cd },
641
9.60k
    { "SkyBlue4", 0x4a708b },
642
9.60k
    { "SlateBlue", 0x6a5acd },
643
9.60k
    { "SlateBlue1", 0x836fff },
644
9.60k
    { "SlateBlue2", 0x7a67ee },
645
9.60k
    { "SlateBlue3", 0x6959cd },
646
9.60k
    { "SlateBlue4", 0x473c8b },
647
9.60k
    { "SlateGray", 0x708090 },
648
9.60k
    { "SlateGray1", 0xc6e2ff },
649
9.60k
    { "SlateGray2", 0xb9d3ee },
650
9.60k
    { "SlateGray3", 0x9fb6cd },
651
9.60k
    { "SlateGray4", 0x6c7b8b },
652
9.60k
    { "SlateGrey", 0x708090 },
653
9.60k
    { "SpringGreen", 0x00ff7f },
654
9.60k
    { "SpringGreen1", 0x00ff7f },
655
9.60k
    { "SpringGreen2", 0x00ee76 },
656
9.60k
    { "SpringGreen3", 0x00cd66 },
657
9.60k
    { "SpringGreen4", 0x008b45 },
658
9.60k
    { "SteelBlue", 0x4682b4 },
659
9.60k
    { "SteelBlue1", 0x63b8ff },
660
9.60k
    { "SteelBlue2", 0x5cacee },
661
9.60k
    { "SteelBlue3", 0x4f94cd },
662
9.60k
    { "SteelBlue4", 0x36648b },
663
9.60k
    { "VioletRed", 0xd02090 },
664
9.60k
    { "VioletRed1", 0xff3e96 },
665
9.60k
    { "VioletRed2", 0xee3a8c },
666
9.60k
    { "VioletRed3", 0xcd3278 },
667
9.60k
    { "VioletRed4", 0x8b2252 },
668
9.60k
    { "WebGray", 0x808080 },
669
9.60k
    { "WebGreen", 0x008000 },
670
9.60k
    { "WebGrey", 0x808080 },
671
9.60k
    { "WebMaroon", 0x800000 },
672
9.60k
    { "WebPurple", 0x800080 },
673
9.60k
    { "WhiteSmoke", 0xf5f5f5 },
674
9.60k
    { "X11Gray", 0xbebebe },
675
9.60k
    { "X11Green", 0x00ff00 },
676
9.60k
    { "X11Grey", 0xbebebe },
677
9.60k
    { "X11Maroon", 0xb03060 },
678
9.60k
    { "X11Purple", 0xa020f0 },
679
9.60k
    { "YellowGreen", 0x9acd32 },
680
9.60k
    { "alice blue", 0xf0f8ff },
681
9.60k
    { "antique white", 0xfaebd7 },
682
9.60k
    { "aqua", 0x00ffff },
683
9.60k
    { "aquamarine", 0x7fffd4 },
684
9.60k
    { "aquamarine1", 0x7fffd4 },
685
9.60k
    { "aquamarine2", 0x76eec6 },
686
9.60k
    { "aquamarine3", 0x66cdaa },
687
9.60k
    { "aquamarine4", 0x458b74 },
688
9.60k
    { "azure", 0xf0ffff },
689
9.60k
    { "azure1", 0xf0ffff },
690
9.60k
    { "azure2", 0xe0eeee },
691
9.60k
    { "azure3", 0xc1cdcd },
692
9.60k
    { "azure4", 0x838b8b },
693
9.60k
    { "beige", 0xf5f5dc },
694
9.60k
    { "bisque", 0xffe4c4 },
695
9.60k
    { "bisque1", 0xffe4c4 },
696
9.60k
    { "bisque2", 0xeed5b7 },
697
9.60k
    { "bisque3", 0xcdb79e },
698
9.60k
    { "bisque4", 0x8b7d6b },
699
9.60k
    { "black", 0x000000 },
700
9.60k
    { "blanched almond", 0xffebcd },
701
9.60k
    { "blue violet", 0x8a2be2 },
702
9.60k
    { "blue", 0x0000ff },
703
9.60k
    { "blue1", 0x0000ff },
704
9.60k
    { "blue2", 0x0000ee },
705
9.60k
    { "blue3", 0x0000cd },
706
9.60k
    { "blue4", 0x00008b },
707
9.60k
    { "brown", 0xa52a2a },
708
9.60k
    { "brown1", 0xff4040 },
709
9.60k
    { "brown2", 0xee3b3b },
710
9.60k
    { "brown3", 0xcd3333 },
711
9.60k
    { "brown4", 0x8b2323 },
712
9.60k
    { "burlywood", 0xdeb887 },
713
9.60k
    { "burlywood1", 0xffd39b },
714
9.60k
    { "burlywood2", 0xeec591 },
715
9.60k
    { "burlywood3", 0xcdaa7d },
716
9.60k
    { "burlywood4", 0x8b7355 },
717
9.60k
    { "cadet blue", 0x5f9ea0 },
718
9.60k
    { "chartreuse", 0x7fff00 },
719
9.60k
    { "chartreuse1", 0x7fff00 },
720
9.60k
    { "chartreuse2", 0x76ee00 },
721
9.60k
    { "chartreuse3", 0x66cd00 },
722
9.60k
    { "chartreuse4", 0x458b00 },
723
9.60k
    { "chocolate", 0xd2691e },
724
9.60k
    { "chocolate1", 0xff7f24 },
725
9.60k
    { "chocolate2", 0xee7621 },
726
9.60k
    { "chocolate3", 0xcd661d },
727
9.60k
    { "chocolate4", 0x8b4513 },
728
9.60k
    { "coral", 0xff7f50 },
729
9.60k
    { "coral1", 0xff7256 },
730
9.60k
    { "coral2", 0xee6a50 },
731
9.60k
    { "coral3", 0xcd5b45 },
732
9.60k
    { "coral4", 0x8b3e2f },
733
9.60k
    { "cornflower blue", 0x6495ed },
734
9.60k
    { "cornsilk", 0xfff8dc },
735
9.60k
    { "cornsilk1", 0xfff8dc },
736
9.60k
    { "cornsilk2", 0xeee8cd },
737
9.60k
    { "cornsilk3", 0xcdc8b1 },
738
9.60k
    { "cornsilk4", 0x8b8878 },
739
9.60k
    { "crimson", 0xdc143c },
740
9.60k
    { "cyan", 0x00ffff },
741
9.60k
    { "cyan1", 0x00ffff },
742
9.60k
    { "cyan2", 0x00eeee },
743
9.60k
    { "cyan3", 0x00cdcd },
744
9.60k
    { "cyan4", 0x008b8b },
745
9.60k
    { "dark blue", 0x00008b },
746
9.60k
    { "dark cyan", 0x008b8b },
747
9.60k
    { "dark goldenrod", 0xb8860b },
748
9.60k
    { "dark gray", 0xa9a9a9 },
749
9.60k
    { "dark green", 0x006400 },
750
9.60k
    { "dark grey", 0xa9a9a9 },
751
9.60k
    { "dark khaki", 0xbdb76b },
752
9.60k
    { "dark magenta", 0x8b008b },
753
9.60k
    { "dark olive green", 0x556b2f },
754
9.60k
    { "dark orange", 0xff8c00 },
755
9.60k
    { "dark orchid", 0x9932cc },
756
9.60k
    { "dark red", 0x8b0000 },
757
9.60k
    { "dark salmon", 0xe9967a },
758
9.60k
    { "dark sea green", 0x8fbc8f },
759
9.60k
    { "dark slate blue", 0x483d8b },
760
9.60k
    { "dark slate gray", 0x2f4f4f },
761
9.60k
    { "dark slate grey", 0x2f4f4f },
762
9.60k
    { "dark turquoise", 0x00ced1 },
763
9.60k
    { "dark violet", 0x9400d3 },
764
9.60k
    { "deep pink", 0xff1493 },
765
9.60k
    { "deep sky blue", 0x00bfff },
766
9.60k
    { "dim gray", 0x696969 },
767
9.60k
    { "dim grey", 0x696969 },
768
9.60k
    { "dodger blue", 0x1e90ff },
769
9.60k
    { "firebrick", 0xb22222 },
770
9.60k
    { "firebrick1", 0xff3030 },
771
9.60k
    { "firebrick2", 0xee2c2c },
772
9.60k
    { "firebrick3", 0xcd2626 },
773
9.60k
    { "firebrick4", 0x8b1a1a },
774
9.60k
    { "floral white", 0xfffaf0 },
775
9.60k
    { "forest green", 0x228b22 },
776
9.60k
    { "fuchsia", 0xff00ff },
777
9.60k
    { "gainsboro", 0xdcdcdc },
778
9.60k
    { "ghost white", 0xf8f8ff },
779
9.60k
    { "gold", 0xffd700 },
780
9.60k
    { "gold1", 0xffd700 },
781
9.60k
    { "gold2", 0xeec900 },
782
9.60k
    { "gold3", 0xcdad00 },
783
9.60k
    { "gold4", 0x8b7500 },
784
9.60k
    { "goldenrod", 0xdaa520 },
785
9.60k
    { "goldenrod1", 0xffc125 },
786
9.60k
    { "goldenrod2", 0xeeb422 },
787
9.60k
    { "goldenrod3", 0xcd9b1d },
788
9.60k
    { "goldenrod4", 0x8b6914 },
789
9.60k
    { "green yellow", 0xadff2f },
790
9.60k
    { "green", 0x00ff00 },
791
9.60k
    { "green1", 0x00ff00 },
792
9.60k
    { "green2", 0x00ee00 },
793
9.60k
    { "green3", 0x00cd00 },
794
9.60k
    { "green4", 0x008b00 },
795
9.60k
    { "honeydew", 0xf0fff0 },
796
9.60k
    { "honeydew1", 0xf0fff0 },
797
9.60k
    { "honeydew2", 0xe0eee0 },
798
9.60k
    { "honeydew3", 0xc1cdc1 },
799
9.60k
    { "honeydew4", 0x838b83 },
800
9.60k
    { "hot pink", 0xff69b4 },
801
9.60k
    { "indian red", 0xcd5c5c },
802
9.60k
    { "indigo", 0x4b0082 },
803
9.60k
    { "ivory", 0xfffff0 },
804
9.60k
    { "ivory1", 0xfffff0 },
805
9.60k
    { "ivory2", 0xeeeee0 },
806
9.60k
    { "ivory3", 0xcdcdc1 },
807
9.60k
    { "ivory4", 0x8b8b83 },
808
9.60k
    { "khaki", 0xf0e68c },
809
9.60k
    { "khaki1", 0xfff68f },
810
9.60k
    { "khaki2", 0xeee685 },
811
9.60k
    { "khaki3", 0xcdc673 },
812
9.60k
    { "khaki4", 0x8b864e },
813
9.60k
    { "lavender blush", 0xfff0f5 },
814
9.60k
    { "lavender", 0xe6e6fa },
815
9.60k
    { "lawn green", 0x7cfc00 },
816
9.60k
    { "lemon chiffon", 0xfffacd },
817
9.60k
    { "light blue", 0xadd8e6 },
818
9.60k
    { "light coral", 0xf08080 },
819
9.60k
    { "light cyan", 0xe0ffff },
820
9.60k
    { "light goldenrod yellow", 0xfafad2 },
821
9.60k
    { "light goldenrod", 0xeedd82 },
822
9.60k
    { "light gray", 0xd3d3d3 },
823
9.60k
    { "light green", 0x90ee90 },
824
9.60k
    { "light grey", 0xd3d3d3 },
825
9.60k
    { "light pink", 0xffb6c1 },
826
9.60k
    { "light salmon", 0xffa07a },
827
9.60k
    { "light sea green", 0x20b2aa },
828
9.60k
    { "light sky blue", 0x87cefa },
829
9.60k
    { "light slate blue", 0x8470ff },
830
9.60k
    { "light slate gray", 0x778899 },
831
9.60k
    { "light slate grey", 0x778899 },
832
9.60k
    { "light steel blue", 0xb0c4de },
833
9.60k
    { "light yellow", 0xffffe0 },
834
9.60k
    { "lime green", 0x32cd32 },
835
9.60k
    { "lime", 0x00ff00 },
836
9.60k
    { "linen", 0xfaf0e6 },
837
9.60k
    { "magenta", 0xff00ff },
838
9.60k
    { "magenta1", 0xff00ff },
839
9.60k
    { "magenta2", 0xee00ee },
840
9.60k
    { "magenta3", 0xcd00cd },
841
9.60k
    { "magenta4", 0x8b008b },
842
9.60k
    { "maroon", 0xb03060 },
843
9.60k
    { "maroon1", 0xff34b3 },
844
9.60k
    { "maroon2", 0xee30a7 },
845
9.60k
    { "maroon3", 0xcd2990 },
846
9.60k
    { "maroon4", 0x8b1c62 },
847
9.60k
    { "medium aquamarine", 0x66cdaa },
848
9.60k
    { "medium blue", 0x0000cd },
849
9.60k
    { "medium orchid", 0xba55d3 },
850
9.60k
    { "medium purple", 0x9370db },
851
9.60k
    { "medium sea green", 0x3cb371 },
852
9.60k
    { "medium slate blue", 0x7b68ee },
853
9.60k
    { "medium spring green", 0x00fa9a },
854
9.60k
    { "medium turquoise", 0x48d1cc },
855
9.60k
    { "medium violet red", 0xc71585 },
856
9.60k
    { "midnight blue", 0x191970 },
857
9.60k
    { "mint cream", 0xf5fffa },
858
9.60k
    { "misty rose", 0xffe4e1 },
859
9.60k
    { "moccasin", 0xffe4b5 },
860
9.60k
    { "navajo white", 0xffdead },
861
9.60k
    { "navy blue", 0x000080 },
862
9.60k
    { "navy", 0x000080 },
863
9.60k
    { "old lace", 0xfdf5e6 },
864
9.60k
    { "olive drab", 0x6b8e23 },
865
9.60k
    { "olive", 0x808000 },
866
9.60k
    { "orange red", 0xff4500 },
867
9.60k
    { "orange", 0xffa500 },
868
9.60k
    { "orange1", 0xffa500 },
869
9.60k
    { "orange2", 0xee9a00 },
870
9.60k
    { "orange3", 0xcd8500 },
871
9.60k
    { "orange4", 0x8b5a00 },
872
9.60k
    { "orchid", 0xda70d6 },
873
9.60k
    { "orchid1", 0xff83fa },
874
9.60k
    { "orchid2", 0xee7ae9 },
875
9.60k
    { "orchid3", 0xcd69c9 },
876
9.60k
    { "orchid4", 0x8b4789 },
877
9.60k
    { "pale goldenrod", 0xeee8aa },
878
9.60k
    { "pale green", 0x98fb98 },
879
9.60k
    { "pale turquoise", 0xafeeee },
880
9.60k
    { "pale violet red", 0xdb7093 },
881
9.60k
    { "papaya whip", 0xffefd5 },
882
9.60k
    { "peach puff", 0xffdab9 },
883
9.60k
    { "peru", 0xcd853f },
884
9.60k
    { "pink", 0xffc0cb },
885
9.60k
    { "pink1", 0xffb5c5 },
886
9.60k
    { "pink2", 0xeea9b8 },
887
9.60k
    { "pink3", 0xcd919e },
888
9.60k
    { "pink4", 0x8b636c },
889
9.60k
    { "plum", 0xdda0dd },
890
9.60k
    { "plum1", 0xffbbff },
891
9.60k
    { "plum2", 0xeeaeee },
892
9.60k
    { "plum3", 0xcd96cd },
893
9.60k
    { "plum4", 0x8b668b },
894
9.60k
    { "powder blue", 0xb0e0e6 },
895
9.60k
    { "purple", 0xa020f0 },
896
9.60k
    { "purple1", 0x9b30ff },
897
9.60k
    { "purple2", 0x912cee },
898
9.60k
    { "purple3", 0x7d26cd },
899
9.60k
    { "purple4", 0x551a8b },
900
9.60k
    { "rebecca purple", 0x663399 },
901
9.60k
    { "red", 0xff0000 },
902
9.60k
    { "red1", 0xff0000 },
903
9.60k
    { "red2", 0xee0000 },
904
9.60k
    { "red3", 0xcd0000 },
905
9.60k
    { "red4", 0x8b0000 },
906
9.60k
    { "rosy brown", 0xbc8f8f },
907
9.60k
    { "royal blue", 0x4169e1 },
908
9.60k
    { "saddle brown", 0x8b4513 },
909
9.60k
    { "salmon", 0xfa8072 },
910
9.60k
    { "salmon1", 0xff8c69 },
911
9.60k
    { "salmon2", 0xee8262 },
912
9.60k
    { "salmon3", 0xcd7054 },
913
9.60k
    { "salmon4", 0x8b4c39 },
914
9.60k
    { "sandy brown", 0xf4a460 },
915
9.60k
    { "sea green", 0x2e8b57 },
916
9.60k
    { "seashell", 0xfff5ee },
917
9.60k
    { "seashell1", 0xfff5ee },
918
9.60k
    { "seashell2", 0xeee5de },
919
9.60k
    { "seashell3", 0xcdc5bf },
920
9.60k
    { "seashell4", 0x8b8682 },
921
9.60k
    { "sienna", 0xa0522d },
922
9.60k
    { "sienna1", 0xff8247 },
923
9.60k
    { "sienna2", 0xee7942 },
924
9.60k
    { "sienna3", 0xcd6839 },
925
9.60k
    { "sienna4", 0x8b4726 },
926
9.60k
    { "silver", 0xc0c0c0 },
927
9.60k
    { "sky blue", 0x87ceeb },
928
9.60k
    { "slate blue", 0x6a5acd },
929
9.60k
    { "slate gray", 0x708090 },
930
9.60k
    { "slate grey", 0x708090 },
931
9.60k
    { "snow", 0xfffafa },
932
9.60k
    { "snow1", 0xfffafa },
933
9.60k
    { "snow2", 0xeee9e9 },
934
9.60k
    { "snow3", 0xcdc9c9 },
935
9.60k
    { "snow4", 0x8b8989 },
936
9.60k
    { "spring green", 0x00ff7f },
937
9.60k
    { "steel blue", 0x4682b4 },
938
9.60k
    { "tan", 0xd2b48c },
939
9.60k
    { "tan1", 0xffa54f },
940
9.60k
    { "tan2", 0xee9a49 },
941
9.60k
    { "tan3", 0xcd853f },
942
9.60k
    { "tan4", 0x8b5a2b },
943
9.60k
    { "teal", 0x008080 },
944
9.60k
    { "thistle", 0xd8bfd8 },
945
9.60k
    { "thistle1", 0xffe1ff },
946
9.60k
    { "thistle2", 0xeed2ee },
947
9.60k
    { "thistle3", 0xcdb5cd },
948
9.60k
    { "thistle4", 0x8b7b8b },
949
9.60k
    { "tomato", 0xff6347 },
950
9.60k
    { "tomato1", 0xff6347 },
951
9.60k
    { "tomato2", 0xee5c42 },
952
9.60k
    { "tomato3", 0xcd4f39 },
953
9.60k
    { "tomato4", 0x8b3626 },
954
9.60k
    { "turquoise", 0x40e0d0 },
955
9.60k
    { "turquoise1", 0x00f5ff },
956
9.60k
    { "turquoise2", 0x00e5ee },
957
9.60k
    { "turquoise3", 0x00c5cd },
958
9.60k
    { "turquoise4", 0x00868b },
959
9.60k
    { "violet red", 0xd02090 },
960
9.60k
    { "violet", 0xee82ee },
961
9.60k
    { "web gray", 0x808080 },
962
9.60k
    { "web green", 0x008000 },
963
9.60k
    { "web grey", 0x808080 },
964
9.60k
    { "web maroon", 0x800000 },
965
9.60k
    { "web purple", 0x800080 },
966
9.60k
    { "wheat", 0xf5deb3 },
967
9.60k
    { "wheat1", 0xffe7ba },
968
9.60k
    { "wheat2", 0xeed8ae },
969
9.60k
    { "wheat3", 0xcdba96 },
970
9.60k
    { "wheat4", 0x8b7e66 },
971
9.60k
    { "white smoke", 0xf5f5f5 },
972
9.60k
    { "white", 0xffffff },
973
9.60k
    { "x11 gray", 0xbebebe },
974
9.60k
    { "x11 green", 0x00ff00 },
975
9.60k
    { "x11 grey", 0xbebebe },
976
9.60k
    { "x11 maroon", 0xb03060 },
977
9.60k
    { "x11 purple", 0xa020f0 },
978
9.60k
    { "yellow green", 0x9acd32 },
979
9.60k
    { "yellow", 0xffff00 },
980
9.60k
    { "yellow1", 0xffff00 },
981
9.60k
    { "yellow2", 0xeeee00 },
982
9.60k
    { "yellow3", 0xcdcd00 },
983
9.60k
    { "yellow4", 0x8b8b00 }
984
9.60k
  };
985
9.60k
  u_int    i;
986
9.60k
  int    c;
987
9.60k
  const char  *errstr;
988
989
9.60k
  if (strncasecmp(name, "grey", 4) == 0 ||
990
9.04k
      strncasecmp(name, "gray", 4) == 0) {
991
1.23k
    if (name[4] == '\0')
992
297
      return (0xbebebe|COLOUR_FLAG_RGB);
993
936
    c = strtonum(name + 4, 0, 100, &errstr);
994
936
    if (errstr != NULL)
995
654
      return (-1);
996
282
    c = round(2.55 * c);
997
282
    if (c < 0 || c > 255)
998
0
      return (-1);
999
282
    return (colour_join_rgb(c, c, c));
1000
282
  }
1001
4.83M
  for (i = 0; i < nitems(colours); i++) {
1002
4.82M
    if (strcasecmp(colours[i].name, name) == 0)
1003
262
      return (colours[i].c|COLOUR_FLAG_RGB);
1004
4.82M
  }
1005
8.10k
  return (-1);
1006
8.36k
}
1007
1008
/* Parse colour from an X11 string. */
1009
int
1010
colour_parseX11(const char *p)
1011
0
{
1012
0
  double   c, m, y, k = 0;
1013
0
  u_int  r, g, b;
1014
0
  size_t   len = strlen(p);
1015
0
  int  colour = -1;
1016
0
  char  *copy;
1017
1018
0
  if ((len == 12 && sscanf(p, "rgb:%02x/%02x/%02x", &r, &g, &b) == 3) ||
1019
0
      (len == 7 && sscanf(p, "#%02x%02x%02x", &r, &g, &b) == 3) ||
1020
0
      sscanf(p, "%d,%d,%d", &r, &g, &b) == 3)
1021
0
    colour = colour_join_rgb(r, g, b);
1022
0
  else if ((len == 18 &&
1023
0
      sscanf(p, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) ||
1024
0
      (len == 13 && sscanf(p, "#%04x%04x%04x", &r, &g, &b) == 3))
1025
0
    colour = colour_join_rgb(r >> 8, g >> 8, b >> 8);
1026
0
  else if ((sscanf(p, "cmyk:%lf/%lf/%lf/%lf", &c, &m, &y, &k) == 4 ||
1027
0
      sscanf(p, "cmy:%lf/%lf/%lf", &c, &m, &y) == 3) &&
1028
0
      c >= 0 && c <= 1 && m >= 0 && m <= 1 &&
1029
0
      y >= 0 && y <= 1 && k >= 0 && k <= 1) {
1030
0
    colour = colour_join_rgb(
1031
0
        (1 - c) * (1 - k) * 255,
1032
0
        (1 - m) * (1 - k) * 255,
1033
0
        (1 - y) * (1 - k) * 255);
1034
0
  } else {
1035
0
    while (len != 0 && *p == ' ') {
1036
0
      p++;
1037
0
      len--;
1038
0
    }
1039
0
    while (len != 0 && p[len - 1] == ' ')
1040
0
      len--;
1041
0
    copy = xstrndup(p, len);
1042
0
    colour = colour_byname(copy);
1043
0
    free(copy);
1044
0
  }
1045
0
  log_debug("%s: %s = %s", __func__, p, colour_tostring(colour));
1046
0
  return (colour);
1047
0
}
1048
1049
/* Initialize palette. */
1050
void
1051
colour_palette_init(struct colour_palette *p)
1052
0
{
1053
0
  p->fg = 8;
1054
0
  p->bg = 8;
1055
0
  p->palette = NULL;
1056
0
  p->default_palette = NULL;
1057
0
}
1058
1059
/* Clear palette. */
1060
void
1061
colour_palette_clear(struct colour_palette *p)
1062
0
{
1063
0
  if (p != NULL) {
1064
0
    p->fg = 8;
1065
0
    p->bg = 8;
1066
0
    free(p->palette);
1067
0
    p->palette = NULL;
1068
0
  }
1069
0
}
1070
1071
/* Free a palette. */
1072
void
1073
colour_palette_free(struct colour_palette *p)
1074
0
{
1075
0
  if (p != NULL) {
1076
0
    free(p->palette);
1077
0
    p->palette = NULL;
1078
0
    free(p->default_palette);
1079
0
    p->default_palette = NULL;
1080
0
  }
1081
0
}
1082
1083
/* Get a colour from a palette. */
1084
int
1085
colour_palette_get(struct colour_palette *p, int n)
1086
0
{
1087
0
  if (p == NULL)
1088
0
    return (-1);
1089
1090
0
  if (n >= 90 && n <= 97)
1091
0
    n = 8 + n - 90;
1092
0
  else if (n & COLOUR_FLAG_256)
1093
0
    n &= ~COLOUR_FLAG_256;
1094
0
  else if (n >= 8)
1095
0
    return (-1);
1096
1097
0
  if (p->palette != NULL && p->palette[n] != -1)
1098
0
    return (p->palette[n]);
1099
0
  if (p->default_palette != NULL && p->default_palette[n] != -1)
1100
0
    return (p->default_palette[n]);
1101
0
  return (-1);
1102
0
}
1103
1104
/* Set a colour in a palette. */
1105
int
1106
colour_palette_set(struct colour_palette *p, int n, int c)
1107
0
{
1108
0
  u_int i;
1109
1110
0
  if (p == NULL || n < 0 || n > 255)
1111
0
    return (0);
1112
1113
0
  if (c == -1 && p->palette == NULL)
1114
0
    return (0);
1115
1116
0
  if (p->palette == NULL) {
1117
0
    p->palette = xcalloc(256, sizeof *p->palette);
1118
0
    for (i = 0; i < 256; i++)
1119
0
      p->palette[i] = -1;
1120
0
  }
1121
0
  p->palette[n] = c;
1122
0
  return (1);
1123
0
}
1124
1125
/* Build palette defaults from an option. */
1126
void
1127
colour_palette_from_option(struct colour_palette *p, struct options *oo)
1128
0
{
1129
0
  struct options_entry    *o;
1130
0
  struct options_array_item *a;
1131
0
  u_int        i, n;
1132
0
  int        c;
1133
1134
0
  if (p == NULL)
1135
0
    return;
1136
1137
0
  o = options_get(oo, "pane-colours");
1138
0
  if ((a = options_array_first(o)) == NULL) {
1139
0
    if (p->default_palette != NULL) {
1140
0
      free(p->default_palette);
1141
0
      p->default_palette = NULL;
1142
0
    }
1143
0
    return;
1144
0
  }
1145
0
  if (p->default_palette == NULL)
1146
0
    p->default_palette = xcalloc(256, sizeof *p->default_palette);
1147
0
  for (i = 0; i < 256; i++)
1148
0
    p->default_palette[i] = -1;
1149
0
  while (a != NULL) {
1150
0
    n = options_array_item_index(a);
1151
0
    if (n < 256) {
1152
0
      c = options_array_item_value(a)->number;
1153
0
      p->default_palette[n] = c;
1154
0
    }
1155
0
    a = options_array_next(a);
1156
0
  }
1157
0
}