Coverage for /usr/lib/python3/dist-packages/colorzero/tables.py: 100%
10 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-02-10 12:38 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-02-10 12:38 +0000
1# vim: set et sw=4 sts=4 fileencoding=utf-8:
2#
3# The colorzero color library
4# Copyright (c) 2016-2018 Dave Jones <dave@waveform.org.uk>
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8#
9# * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# * Neither the name of the copyright holder nor the
15# names of its contributors may be used to endorse or promote products
16# derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
30"""
31Defines the available color names, derived from the `CSS Color Module`_ Level 3
32Specification, section 4.3, along with tables for the original DOS colors, and
33XTerm colors (for :func:`format` output).
35.. _CSS Color Module: http://www.w3.org/TR/css3-color/#svg-color
36"""
38from __future__ import (
39 unicode_literals,
40 print_function,
41 division,
42 absolute_import,
43)
46def _transpose(table):
47 # Swap keys and values in a dict, but in the case of duplicated keys, use
48 # the first encountered instead of the last
49 result = {}
50 for k, v in table.items():
51 result.setdefault(v, k)
52 return result
55DOS_COLORS = _transpose({
56# Bold, Index: (R, G, B),
57 (False, 0): (0, 0, 0),
58 (False, 1): (128, 0, 0),
59 (False, 2): (0, 128, 0),
60 (False, 3): (128, 128, 0),
61 (False, 4): (0, 0, 128),
62 (False, 5): (128, 0, 128),
63 (False, 6): (0, 128, 128),
64 (False, 7): (192, 192, 192),
65 (True, 0): (128, 128, 128),
66 (True, 1): (255, 0, 0),
67 (True, 2): (0, 255, 0),
68 (True, 3): (255, 255, 0),
69 (True, 4): (0, 0, 255),
70 (True, 5): (255, 0, 255),
71 (True, 6): (0, 255, 255),
72 (True, 7): (255, 255, 255),
73})
76XTERM_COLORS = _transpose({
77# Index: (R, G, B)
78 0: (0, 0, 0),
79 1: (128, 0, 0),
80 2: (0, 128, 0),
81 3: (128, 128, 0),
82 4: (0, 0, 128),
83 5: (128, 0, 128),
84 6: (0, 128, 128),
85 7: (192, 192, 192),
86 8: (128, 128, 128),
87 9: (255, 0, 0),
88 10: (0, 255, 0),
89 11: (255, 255, 0),
90 12: (0, 0, 255),
91 13: (255, 0, 255),
92 14: (0, 255, 255),
93 15: (255, 255, 255),
94 16: (0, 0, 0),
95 17: (0, 0, 95),
96 18: (0, 0, 135),
97 19: (0, 0, 175),
98 20: (0, 0, 215),
99 21: (0, 0, 255),
100 22: (0, 95, 0),
101 23: (0, 95, 95),
102 24: (0, 95, 135),
103 25: (0, 95, 175),
104 26: (0, 95, 215),
105 27: (0, 95, 255),
106 28: (0, 135, 0),
107 29: (0, 135, 95),
108 30: (0, 135, 135),
109 31: (0, 135, 175),
110 32: (0, 135, 215),
111 33: (0, 135, 255),
112 34: (0, 175, 0),
113 35: (0, 175, 95),
114 36: (0, 175, 135),
115 37: (0, 175, 175),
116 38: (0, 175, 215),
117 39: (0, 175, 255),
118 40: (0, 215, 0),
119 41: (0, 215, 95),
120 42: (0, 215, 135),
121 43: (0, 215, 175),
122 44: (0, 215, 215),
123 45: (0, 215, 255),
124 46: (0, 255, 0),
125 47: (0, 255, 95),
126 48: (0, 255, 135),
127 49: (0, 255, 175),
128 50: (0, 255, 215),
129 51: (0, 255, 255),
130 52: (95, 0, 0),
131 53: (95, 0, 95),
132 54: (95, 0, 135),
133 55: (95, 0, 175),
134 56: (95, 0, 215),
135 57: (95, 0, 255),
136 58: (95, 95, 0),
137 59: (95, 95, 95),
138 60: (95, 95, 135),
139 61: (95, 95, 175),
140 62: (95, 95, 215),
141 63: (95, 95, 255),
142 64: (95, 135, 0),
143 65: (95, 135, 95),
144 66: (95, 135, 135),
145 67: (95, 135, 175),
146 68: (95, 135, 215),
147 69: (95, 135, 255),
148 70: (95, 175, 0),
149 71: (95, 175, 95),
150 72: (95, 175, 135),
151 73: (95, 175, 175),
152 74: (95, 175, 215),
153 75: (95, 175, 255),
154 76: (95, 215, 0),
155 77: (95, 215, 95),
156 78: (95, 215, 135),
157 79: (95, 215, 175),
158 80: (95, 215, 215),
159 81: (95, 215, 255),
160 82: (95, 255, 0),
161 83: (95, 255, 95),
162 84: (95, 255, 135),
163 85: (95, 255, 175),
164 86: (95, 255, 215),
165 87: (95, 255, 255),
166 88: (135, 0, 0),
167 89: (135, 0, 95),
168 90: (135, 0, 135),
169 91: (135, 0, 175),
170 92: (135, 0, 215),
171 93: (135, 0, 255),
172 94: (135, 95, 0),
173 95: (135, 95, 95),
174 96: (135, 95, 135),
175 97: (135, 95, 175),
176 98: (135, 95, 215),
177 99: (135, 95, 255),
178 100: (135, 135, 0),
179 101: (135, 135, 95),
180 102: (135, 135, 135),
181 103: (135, 135, 175),
182 104: (135, 135, 215),
183 105: (135, 135, 255),
184 106: (135, 175, 0),
185 107: (135, 175, 95),
186 108: (135, 175, 135),
187 109: (135, 175, 175),
188 110: (135, 175, 215),
189 111: (135, 175, 255),
190 112: (135, 215, 0),
191 113: (135, 215, 95),
192 114: (135, 215, 135),
193 115: (135, 215, 175),
194 116: (135, 215, 215),
195 117: (135, 215, 255),
196 118: (135, 255, 0),
197 119: (135, 255, 95),
198 120: (135, 255, 135),
199 121: (135, 255, 175),
200 122: (135, 255, 215),
201 123: (135, 255, 255),
202 124: (175, 0, 0),
203 125: (175, 0, 95),
204 126: (175, 0, 135),
205 127: (175, 0, 175),
206 128: (175, 0, 215),
207 129: (175, 0, 255),
208 130: (175, 95, 0),
209 131: (175, 95, 95),
210 132: (175, 95, 135),
211 133: (175, 95, 175),
212 134: (175, 95, 215),
213 135: (175, 95, 255),
214 136: (175, 135, 0),
215 137: (175, 135, 95),
216 138: (175, 135, 135),
217 139: (175, 135, 175),
218 140: (175, 135, 215),
219 141: (175, 135, 255),
220 142: (175, 175, 0),
221 143: (175, 175, 95),
222 144: (175, 175, 135),
223 145: (175, 175, 175),
224 146: (175, 175, 215),
225 147: (175, 175, 255),
226 148: (175, 215, 0),
227 149: (175, 215, 95),
228 150: (175, 215, 135),
229 151: (175, 215, 175),
230 152: (175, 215, 215),
231 153: (175, 215, 255),
232 154: (175, 255, 0),
233 155: (175, 255, 95),
234 156: (175, 255, 135),
235 157: (175, 255, 175),
236 158: (175, 255, 215),
237 159: (175, 255, 255),
238 160: (215, 0, 0),
239 161: (215, 0, 95),
240 162: (215, 0, 135),
241 163: (215, 0, 175),
242 164: (215, 0, 215),
243 165: (215, 0, 255),
244 166: (215, 95, 0),
245 167: (215, 95, 95),
246 168: (215, 95, 135),
247 169: (215, 95, 175),
248 170: (215, 95, 215),
249 171: (215, 95, 255),
250 172: (215, 135, 0),
251 173: (215, 135, 95),
252 174: (215, 135, 135),
253 175: (215, 135, 175),
254 176: (215, 135, 215),
255 177: (215, 135, 255),
256 178: (215, 175, 0),
257 179: (215, 175, 95),
258 180: (215, 175, 135),
259 181: (215, 175, 175),
260 182: (215, 175, 215),
261 183: (215, 175, 255),
262 184: (215, 215, 0),
263 185: (215, 215, 95),
264 186: (215, 215, 135),
265 187: (215, 215, 175),
266 188: (215, 215, 215),
267 189: (215, 215, 255),
268 190: (215, 255, 0),
269 191: (215, 255, 95),
270 192: (215, 255, 135),
271 193: (215, 255, 175),
272 194: (215, 255, 215),
273 195: (215, 255, 255),
274 196: (255, 0, 0),
275 197: (255, 0, 95),
276 198: (255, 0, 135),
277 199: (255, 0, 175),
278 200: (255, 0, 215),
279 201: (255, 0, 255),
280 202: (255, 95, 0),
281 203: (255, 95, 95),
282 204: (255, 95, 135),
283 205: (255, 95, 175),
284 206: (255, 95, 215),
285 207: (255, 95, 255),
286 208: (255, 135, 0),
287 209: (255, 135, 95),
288 210: (255, 135, 135),
289 211: (255, 135, 175),
290 212: (255, 135, 215),
291 213: (255, 135, 255),
292 214: (255, 175, 0),
293 215: (255, 175, 95),
294 216: (255, 175, 135),
295 217: (255, 175, 175),
296 218: (255, 175, 215),
297 219: (255, 175, 255),
298 220: (255, 215, 0),
299 221: (255, 215, 95),
300 222: (255, 215, 135),
301 223: (255, 215, 175),
302 224: (255, 215, 215),
303 225: (255, 215, 255),
304 226: (255, 255, 0),
305 227: (255, 255, 95),
306 228: (255, 255, 135),
307 229: (255, 255, 175),
308 230: (255, 255, 215),
309 231: (255, 255, 255),
310 232: (8, 8, 8),
311 233: (18, 18, 18),
312 234: (28, 28, 28),
313 235: (38, 38, 38),
314 236: (48, 48, 48),
315 237: (58, 58, 58),
316 238: (68, 68, 68),
317 239: (78, 78, 78),
318 240: (88, 88, 88),
319 241: (98, 98, 98),
320 242: (108, 108, 108),
321 243: (118, 118, 118),
322 244: (128, 128, 128),
323 245: (138, 138, 138),
324 246: (148, 148, 148),
325 247: (158, 158, 158),
326 248: (168, 168, 168),
327 249: (178, 178, 178),
328 250: (188, 188, 188),
329 251: (198, 198, 198),
330 252: (208, 208, 208),
331 253: (218, 218, 218),
332 254: (228, 228, 228),
333 255: (238, 238, 238),
334})
337NAMED_COLORS = {
338 'aliceblue': '#f0f8ff',
339 'antiquewhite': '#faebd7',
340 'aqua': '#00ffff',
341 'aquamarine': '#7fffd4',
342 'azure': '#f0ffff',
343 'beige': '#f5f5dc',
344 'bisque': '#ffe4c4',
345 'black': '#000000',
346 'blanchedalmond': '#ffebcd',
347 'blue': '#0000ff',
348 'blueviolet': '#8a2be2',
349 'brown': '#a52a2a',
350 'burlywood': '#deb887',
351 'cadetblue': '#5f9ea0',
352 'chartreuse': '#7fff00',
353 'chocolate': '#d2691e',
354 'coral': '#ff7f50',
355 'cornflowerblue': '#6495ed',
356 'cornsilk': '#fff8dc',
357 'crimson': '#dc143c',
358 'cyan': '#00ffff',
359 'darkblue': '#00008b',
360 'darkcyan': '#008b8b',
361 'darkgoldenrod': '#b8860b',
362 'darkgray': '#a9a9a9',
363 'darkgreen': '#006400',
364 'darkgrey': '#a9a9a9',
365 'darkkhaki': '#bdb76b',
366 'darkmagenta': '#8b008b',
367 'darkolivegreen': '#556b2f',
368 'darkorange': '#ff8c00',
369 'darkorchid': '#9932cc',
370 'darkred': '#8b0000',
371 'darksalmon': '#e9967a',
372 'darkseagreen': '#8fbc8f',
373 'darkslateblue': '#483d8b',
374 'darkslategray': '#2f4f4f',
375 'darkslategrey': '#2f4f4f',
376 'darkturquoise': '#00ced1',
377 'darkviolet': '#9400d3',
378 'deeppink': '#ff1493',
379 'deepskyblue': '#00bfff',
380 'dimgray': '#696969',
381 'dimgrey': '#696969',
382 'dodgerblue': '#1e90ff',
383 'firebrick': '#b22222',
384 'floralwhite': '#fffaf0',
385 'forestgreen': '#228b22',
386 'fuchsia': '#ff00ff',
387 'gainsboro': '#dcdcdc',
388 'ghostwhite': '#f8f8ff',
389 'gold': '#ffd700',
390 'goldenrod': '#daa520',
391 'gray': '#808080',
392 'green': '#008000',
393 'greenyellow': '#adff2f',
394 'grey': '#808080',
395 'honeydew': '#f0fff0',
396 'hotpink': '#ff69b4',
397 'indianred': '#cd5c5c',
398 'indigo': '#4b0082',
399 'ivory': '#fffff0',
400 'khaki': '#f0e68c',
401 'lavender': '#e6e6fa',
402 'lavenderblush': '#fff0f5',
403 'lawngreen': '#7cfc00',
404 'lemonchiffon': '#fffacd',
405 'lightblue': '#add8e6',
406 'lightcoral': '#f08080',
407 'lightcyan': '#e0ffff',
408 'lightgoldenrodyellow': '#fafad2',
409 'lightgray': '#d3d3d3',
410 'lightgreen': '#90ee90',
411 'lightgrey': '#d3d3d3',
412 'lightpink': '#ffb6c1',
413 'lightsalmon': '#ffa07a',
414 'lightseagreen': '#20b2aa',
415 'lightskyblue': '#87cefa',
416 'lightslategray': '#778899',
417 'lightslategrey': '#778899',
418 'lightsteelblue': '#b0c4de',
419 'lightyellow': '#ffffe0',
420 'lime': '#00ff00',
421 'limegreen': '#32cd32',
422 'linen': '#faf0e6',
423 'magenta': '#ff00ff',
424 'maroon': '#800000',
425 'mediumaquamarine': '#66cdaa',
426 'mediumblue': '#0000cd',
427 'mediumorchid': '#ba55d3',
428 'mediumpurple': '#9370db',
429 'mediumseagreen': '#3cb371',
430 'mediumslateblue': '#7b68ee',
431 'mediumspringgreen': '#00fa9a',
432 'mediumturquoise': '#48d1cc',
433 'mediumvioletred': '#c71585',
434 'midnightblue': '#191970',
435 'mintcream': '#f5fffa',
436 'mistyrose': '#ffe4e1',
437 'moccasin': '#ffe4b5',
438 'navajowhite': '#ffdead',
439 'navy': '#000080',
440 'oldlace': '#fdf5e6',
441 'olive': '#808000',
442 'olivedrab': '#6b8e23',
443 'orange': '#ffa500',
444 'orangered': '#ff4500',
445 'orchid': '#da70d6',
446 'palegoldenrod': '#eee8aa',
447 'palegreen': '#98fb98',
448 'paleturquoise': '#afeeee',
449 'palevioletred': '#db7093',
450 'papayawhip': '#ffefd5',
451 'peachpuff': '#ffdab9',
452 'peru': '#cd853f',
453 'pink': '#ffc0cb',
454 'plum': '#dda0dd',
455 'powderblue': '#b0e0e6',
456 'purple': '#800080',
457 'red': '#ff0000',
458 'rosybrown': '#bc8f8f',
459 'royalblue': '#4169e1',
460 'saddlebrown': '#8b4513',
461 'salmon': '#fa8072',
462 'sandybrown': '#f4a460',
463 'seagreen': '#2e8b57',
464 'seashell': '#fff5ee',
465 'sienna': '#a0522d',
466 'silver': '#c0c0c0',
467 'skyblue': '#87ceeb',
468 'slateblue': '#6a5acd',
469 'slategray': '#708090',
470 'slategrey': '#708090',
471 'snow': '#fffafa',
472 'springgreen': '#00ff7f',
473 'steelblue': '#4682b4',
474 'tan': '#d2b48c',
475 'teal': '#008080',
476 'thistle': '#d8bfd8',
477 'tomato': '#ff6347',
478 'turquoise': '#40e0d0',
479 'violet': '#ee82ee',
480 'wheat': '#f5deb3',
481 'white': '#ffffff',
482 'whitesmoke': '#f5f5f5',
483 'yellow': '#ffff00',
484 'yellowgreen': '#9acd32',
485}