proto-tinker-wc 0.1.86 → 0.1.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,2200 +15,6 @@ const Radio = props => {
15
15
  index.h("path", { d: "M0 0h24v24H0z", fill: "none" })));
16
16
  };
17
17
 
18
- var colorString = {exports: {}};
19
-
20
- var colorName$1;
21
- var hasRequiredColorName$1;
22
-
23
- function requireColorName$1 () {
24
- if (hasRequiredColorName$1) return colorName$1;
25
- hasRequiredColorName$1 = 1;
26
-
27
- colorName$1 = {
28
- "aliceblue": [240, 248, 255],
29
- "antiquewhite": [250, 235, 215],
30
- "aqua": [0, 255, 255],
31
- "aquamarine": [127, 255, 212],
32
- "azure": [240, 255, 255],
33
- "beige": [245, 245, 220],
34
- "bisque": [255, 228, 196],
35
- "black": [0, 0, 0],
36
- "blanchedalmond": [255, 235, 205],
37
- "blue": [0, 0, 255],
38
- "blueviolet": [138, 43, 226],
39
- "brown": [165, 42, 42],
40
- "burlywood": [222, 184, 135],
41
- "cadetblue": [95, 158, 160],
42
- "chartreuse": [127, 255, 0],
43
- "chocolate": [210, 105, 30],
44
- "coral": [255, 127, 80],
45
- "cornflowerblue": [100, 149, 237],
46
- "cornsilk": [255, 248, 220],
47
- "crimson": [220, 20, 60],
48
- "cyan": [0, 255, 255],
49
- "darkblue": [0, 0, 139],
50
- "darkcyan": [0, 139, 139],
51
- "darkgoldenrod": [184, 134, 11],
52
- "darkgray": [169, 169, 169],
53
- "darkgreen": [0, 100, 0],
54
- "darkgrey": [169, 169, 169],
55
- "darkkhaki": [189, 183, 107],
56
- "darkmagenta": [139, 0, 139],
57
- "darkolivegreen": [85, 107, 47],
58
- "darkorange": [255, 140, 0],
59
- "darkorchid": [153, 50, 204],
60
- "darkred": [139, 0, 0],
61
- "darksalmon": [233, 150, 122],
62
- "darkseagreen": [143, 188, 143],
63
- "darkslateblue": [72, 61, 139],
64
- "darkslategray": [47, 79, 79],
65
- "darkslategrey": [47, 79, 79],
66
- "darkturquoise": [0, 206, 209],
67
- "darkviolet": [148, 0, 211],
68
- "deeppink": [255, 20, 147],
69
- "deepskyblue": [0, 191, 255],
70
- "dimgray": [105, 105, 105],
71
- "dimgrey": [105, 105, 105],
72
- "dodgerblue": [30, 144, 255],
73
- "firebrick": [178, 34, 34],
74
- "floralwhite": [255, 250, 240],
75
- "forestgreen": [34, 139, 34],
76
- "fuchsia": [255, 0, 255],
77
- "gainsboro": [220, 220, 220],
78
- "ghostwhite": [248, 248, 255],
79
- "gold": [255, 215, 0],
80
- "goldenrod": [218, 165, 32],
81
- "gray": [128, 128, 128],
82
- "green": [0, 128, 0],
83
- "greenyellow": [173, 255, 47],
84
- "grey": [128, 128, 128],
85
- "honeydew": [240, 255, 240],
86
- "hotpink": [255, 105, 180],
87
- "indianred": [205, 92, 92],
88
- "indigo": [75, 0, 130],
89
- "ivory": [255, 255, 240],
90
- "khaki": [240, 230, 140],
91
- "lavender": [230, 230, 250],
92
- "lavenderblush": [255, 240, 245],
93
- "lawngreen": [124, 252, 0],
94
- "lemonchiffon": [255, 250, 205],
95
- "lightblue": [173, 216, 230],
96
- "lightcoral": [240, 128, 128],
97
- "lightcyan": [224, 255, 255],
98
- "lightgoldenrodyellow": [250, 250, 210],
99
- "lightgray": [211, 211, 211],
100
- "lightgreen": [144, 238, 144],
101
- "lightgrey": [211, 211, 211],
102
- "lightpink": [255, 182, 193],
103
- "lightsalmon": [255, 160, 122],
104
- "lightseagreen": [32, 178, 170],
105
- "lightskyblue": [135, 206, 250],
106
- "lightslategray": [119, 136, 153],
107
- "lightslategrey": [119, 136, 153],
108
- "lightsteelblue": [176, 196, 222],
109
- "lightyellow": [255, 255, 224],
110
- "lime": [0, 255, 0],
111
- "limegreen": [50, 205, 50],
112
- "linen": [250, 240, 230],
113
- "magenta": [255, 0, 255],
114
- "maroon": [128, 0, 0],
115
- "mediumaquamarine": [102, 205, 170],
116
- "mediumblue": [0, 0, 205],
117
- "mediumorchid": [186, 85, 211],
118
- "mediumpurple": [147, 112, 219],
119
- "mediumseagreen": [60, 179, 113],
120
- "mediumslateblue": [123, 104, 238],
121
- "mediumspringgreen": [0, 250, 154],
122
- "mediumturquoise": [72, 209, 204],
123
- "mediumvioletred": [199, 21, 133],
124
- "midnightblue": [25, 25, 112],
125
- "mintcream": [245, 255, 250],
126
- "mistyrose": [255, 228, 225],
127
- "moccasin": [255, 228, 181],
128
- "navajowhite": [255, 222, 173],
129
- "navy": [0, 0, 128],
130
- "oldlace": [253, 245, 230],
131
- "olive": [128, 128, 0],
132
- "olivedrab": [107, 142, 35],
133
- "orange": [255, 165, 0],
134
- "orangered": [255, 69, 0],
135
- "orchid": [218, 112, 214],
136
- "palegoldenrod": [238, 232, 170],
137
- "palegreen": [152, 251, 152],
138
- "paleturquoise": [175, 238, 238],
139
- "palevioletred": [219, 112, 147],
140
- "papayawhip": [255, 239, 213],
141
- "peachpuff": [255, 218, 185],
142
- "peru": [205, 133, 63],
143
- "pink": [255, 192, 203],
144
- "plum": [221, 160, 221],
145
- "powderblue": [176, 224, 230],
146
- "purple": [128, 0, 128],
147
- "rebeccapurple": [102, 51, 153],
148
- "red": [255, 0, 0],
149
- "rosybrown": [188, 143, 143],
150
- "royalblue": [65, 105, 225],
151
- "saddlebrown": [139, 69, 19],
152
- "salmon": [250, 128, 114],
153
- "sandybrown": [244, 164, 96],
154
- "seagreen": [46, 139, 87],
155
- "seashell": [255, 245, 238],
156
- "sienna": [160, 82, 45],
157
- "silver": [192, 192, 192],
158
- "skyblue": [135, 206, 235],
159
- "slateblue": [106, 90, 205],
160
- "slategray": [112, 128, 144],
161
- "slategrey": [112, 128, 144],
162
- "snow": [255, 250, 250],
163
- "springgreen": [0, 255, 127],
164
- "steelblue": [70, 130, 180],
165
- "tan": [210, 180, 140],
166
- "teal": [0, 128, 128],
167
- "thistle": [216, 191, 216],
168
- "tomato": [255, 99, 71],
169
- "turquoise": [64, 224, 208],
170
- "violet": [238, 130, 238],
171
- "wheat": [245, 222, 179],
172
- "white": [255, 255, 255],
173
- "whitesmoke": [245, 245, 245],
174
- "yellow": [255, 255, 0],
175
- "yellowgreen": [154, 205, 50]
176
- };
177
- return colorName$1;
178
- }
179
-
180
- var simpleSwizzle = {exports: {}};
181
-
182
- var isArrayish;
183
- var hasRequiredIsArrayish;
184
-
185
- function requireIsArrayish () {
186
- if (hasRequiredIsArrayish) return isArrayish;
187
- hasRequiredIsArrayish = 1;
188
- isArrayish = function isArrayish(obj) {
189
- if (!obj || typeof obj === 'string') {
190
- return false;
191
- }
192
-
193
- return obj instanceof Array || Array.isArray(obj) ||
194
- (obj.length >= 0 && (obj.splice instanceof Function ||
195
- (Object.getOwnPropertyDescriptor(obj, (obj.length - 1)) && obj.constructor.name !== 'String')));
196
- };
197
- return isArrayish;
198
- }
199
-
200
- var hasRequiredSimpleSwizzle;
201
-
202
- function requireSimpleSwizzle () {
203
- if (hasRequiredSimpleSwizzle) return simpleSwizzle.exports;
204
- hasRequiredSimpleSwizzle = 1;
205
-
206
- var isArrayish = requireIsArrayish();
207
-
208
- var concat = Array.prototype.concat;
209
- var slice = Array.prototype.slice;
210
-
211
- var swizzle = simpleSwizzle.exports = function swizzle(args) {
212
- var results = [];
213
-
214
- for (var i = 0, len = args.length; i < len; i++) {
215
- var arg = args[i];
216
-
217
- if (isArrayish(arg)) {
218
- // http://jsperf.com/javascript-array-concat-vs-push/98
219
- results = concat.call(results, slice.call(arg));
220
- } else {
221
- results.push(arg);
222
- }
223
- }
224
-
225
- return results;
226
- };
227
-
228
- swizzle.wrap = function (fn) {
229
- return function () {
230
- return fn(swizzle(arguments));
231
- };
232
- };
233
- return simpleSwizzle.exports;
234
- }
235
-
236
- /* MIT license */
237
-
238
- var hasRequiredColorString;
239
-
240
- function requireColorString () {
241
- if (hasRequiredColorString) return colorString.exports;
242
- hasRequiredColorString = 1;
243
- var colorNames = requireColorName$1();
244
- var swizzle = requireSimpleSwizzle();
245
- var hasOwnProperty = Object.hasOwnProperty;
246
-
247
- var reverseNames = Object.create(null);
248
-
249
- // create a list of reverse color names
250
- for (var name in colorNames) {
251
- if (hasOwnProperty.call(colorNames, name)) {
252
- reverseNames[colorNames[name]] = name;
253
- }
254
- }
255
-
256
- var cs = colorString.exports = {
257
- to: {},
258
- get: {}
259
- };
260
-
261
- cs.get = function (string) {
262
- var prefix = string.substring(0, 3).toLowerCase();
263
- var val;
264
- var model;
265
- switch (prefix) {
266
- case 'hsl':
267
- val = cs.get.hsl(string);
268
- model = 'hsl';
269
- break;
270
- case 'hwb':
271
- val = cs.get.hwb(string);
272
- model = 'hwb';
273
- break;
274
- default:
275
- val = cs.get.rgb(string);
276
- model = 'rgb';
277
- break;
278
- }
279
-
280
- if (!val) {
281
- return null;
282
- }
283
-
284
- return {model: model, value: val};
285
- };
286
-
287
- cs.get.rgb = function (string) {
288
- if (!string) {
289
- return null;
290
- }
291
-
292
- var abbr = /^#([a-f0-9]{3,4})$/i;
293
- var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
294
- var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
295
- var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
296
- var keyword = /^(\w+)$/;
297
-
298
- var rgb = [0, 0, 0, 1];
299
- var match;
300
- var i;
301
- var hexAlpha;
302
-
303
- if (match = string.match(hex)) {
304
- hexAlpha = match[2];
305
- match = match[1];
306
-
307
- for (i = 0; i < 3; i++) {
308
- // https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
309
- var i2 = i * 2;
310
- rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
311
- }
312
-
313
- if (hexAlpha) {
314
- rgb[3] = parseInt(hexAlpha, 16) / 255;
315
- }
316
- } else if (match = string.match(abbr)) {
317
- match = match[1];
318
- hexAlpha = match[3];
319
-
320
- for (i = 0; i < 3; i++) {
321
- rgb[i] = parseInt(match[i] + match[i], 16);
322
- }
323
-
324
- if (hexAlpha) {
325
- rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
326
- }
327
- } else if (match = string.match(rgba)) {
328
- for (i = 0; i < 3; i++) {
329
- rgb[i] = parseInt(match[i + 1], 0);
330
- }
331
-
332
- if (match[4]) {
333
- if (match[5]) {
334
- rgb[3] = parseFloat(match[4]) * 0.01;
335
- } else {
336
- rgb[3] = parseFloat(match[4]);
337
- }
338
- }
339
- } else if (match = string.match(per)) {
340
- for (i = 0; i < 3; i++) {
341
- rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
342
- }
343
-
344
- if (match[4]) {
345
- if (match[5]) {
346
- rgb[3] = parseFloat(match[4]) * 0.01;
347
- } else {
348
- rgb[3] = parseFloat(match[4]);
349
- }
350
- }
351
- } else if (match = string.match(keyword)) {
352
- if (match[1] === 'transparent') {
353
- return [0, 0, 0, 0];
354
- }
355
-
356
- if (!hasOwnProperty.call(colorNames, match[1])) {
357
- return null;
358
- }
359
-
360
- rgb = colorNames[match[1]];
361
- rgb[3] = 1;
362
-
363
- return rgb;
364
- } else {
365
- return null;
366
- }
367
-
368
- for (i = 0; i < 3; i++) {
369
- rgb[i] = clamp(rgb[i], 0, 255);
370
- }
371
- rgb[3] = clamp(rgb[3], 0, 1);
372
-
373
- return rgb;
374
- };
375
-
376
- cs.get.hsl = function (string) {
377
- if (!string) {
378
- return null;
379
- }
380
-
381
- var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
382
- var match = string.match(hsl);
383
-
384
- if (match) {
385
- var alpha = parseFloat(match[4]);
386
- var h = ((parseFloat(match[1]) % 360) + 360) % 360;
387
- var s = clamp(parseFloat(match[2]), 0, 100);
388
- var l = clamp(parseFloat(match[3]), 0, 100);
389
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
390
-
391
- return [h, s, l, a];
392
- }
393
-
394
- return null;
395
- };
396
-
397
- cs.get.hwb = function (string) {
398
- if (!string) {
399
- return null;
400
- }
401
-
402
- var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
403
- var match = string.match(hwb);
404
-
405
- if (match) {
406
- var alpha = parseFloat(match[4]);
407
- var h = ((parseFloat(match[1]) % 360) + 360) % 360;
408
- var w = clamp(parseFloat(match[2]), 0, 100);
409
- var b = clamp(parseFloat(match[3]), 0, 100);
410
- var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
411
- return [h, w, b, a];
412
- }
413
-
414
- return null;
415
- };
416
-
417
- cs.to.hex = function () {
418
- var rgba = swizzle(arguments);
419
-
420
- return (
421
- '#' +
422
- hexDouble(rgba[0]) +
423
- hexDouble(rgba[1]) +
424
- hexDouble(rgba[2]) +
425
- (rgba[3] < 1
426
- ? (hexDouble(Math.round(rgba[3] * 255)))
427
- : '')
428
- );
429
- };
430
-
431
- cs.to.rgb = function () {
432
- var rgba = swizzle(arguments);
433
-
434
- return rgba.length < 4 || rgba[3] === 1
435
- ? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
436
- : 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
437
- };
438
-
439
- cs.to.rgb.percent = function () {
440
- var rgba = swizzle(arguments);
441
-
442
- var r = Math.round(rgba[0] / 255 * 100);
443
- var g = Math.round(rgba[1] / 255 * 100);
444
- var b = Math.round(rgba[2] / 255 * 100);
445
-
446
- return rgba.length < 4 || rgba[3] === 1
447
- ? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
448
- : 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
449
- };
450
-
451
- cs.to.hsl = function () {
452
- var hsla = swizzle(arguments);
453
- return hsla.length < 4 || hsla[3] === 1
454
- ? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
455
- : 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
456
- };
457
-
458
- // hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
459
- // (hwb have alpha optional & 1 is default value)
460
- cs.to.hwb = function () {
461
- var hwba = swizzle(arguments);
462
-
463
- var a = '';
464
- if (hwba.length >= 4 && hwba[3] !== 1) {
465
- a = ', ' + hwba[3];
466
- }
467
-
468
- return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
469
- };
470
-
471
- cs.to.keyword = function (rgb) {
472
- return reverseNames[rgb.slice(0, 3)];
473
- };
474
-
475
- // helpers
476
- function clamp(num, min, max) {
477
- return Math.min(Math.max(min, num), max);
478
- }
479
-
480
- function hexDouble(num) {
481
- var str = Math.round(num).toString(16).toUpperCase();
482
- return (str.length < 2) ? '0' + str : str;
483
- }
484
- return colorString.exports;
485
- }
486
-
487
- var conversions = {exports: {}};
488
-
489
- var colorName;
490
- var hasRequiredColorName;
491
-
492
- function requireColorName () {
493
- if (hasRequiredColorName) return colorName;
494
- hasRequiredColorName = 1;
495
-
496
- colorName = {
497
- "aliceblue": [240, 248, 255],
498
- "antiquewhite": [250, 235, 215],
499
- "aqua": [0, 255, 255],
500
- "aquamarine": [127, 255, 212],
501
- "azure": [240, 255, 255],
502
- "beige": [245, 245, 220],
503
- "bisque": [255, 228, 196],
504
- "black": [0, 0, 0],
505
- "blanchedalmond": [255, 235, 205],
506
- "blue": [0, 0, 255],
507
- "blueviolet": [138, 43, 226],
508
- "brown": [165, 42, 42],
509
- "burlywood": [222, 184, 135],
510
- "cadetblue": [95, 158, 160],
511
- "chartreuse": [127, 255, 0],
512
- "chocolate": [210, 105, 30],
513
- "coral": [255, 127, 80],
514
- "cornflowerblue": [100, 149, 237],
515
- "cornsilk": [255, 248, 220],
516
- "crimson": [220, 20, 60],
517
- "cyan": [0, 255, 255],
518
- "darkblue": [0, 0, 139],
519
- "darkcyan": [0, 139, 139],
520
- "darkgoldenrod": [184, 134, 11],
521
- "darkgray": [169, 169, 169],
522
- "darkgreen": [0, 100, 0],
523
- "darkgrey": [169, 169, 169],
524
- "darkkhaki": [189, 183, 107],
525
- "darkmagenta": [139, 0, 139],
526
- "darkolivegreen": [85, 107, 47],
527
- "darkorange": [255, 140, 0],
528
- "darkorchid": [153, 50, 204],
529
- "darkred": [139, 0, 0],
530
- "darksalmon": [233, 150, 122],
531
- "darkseagreen": [143, 188, 143],
532
- "darkslateblue": [72, 61, 139],
533
- "darkslategray": [47, 79, 79],
534
- "darkslategrey": [47, 79, 79],
535
- "darkturquoise": [0, 206, 209],
536
- "darkviolet": [148, 0, 211],
537
- "deeppink": [255, 20, 147],
538
- "deepskyblue": [0, 191, 255],
539
- "dimgray": [105, 105, 105],
540
- "dimgrey": [105, 105, 105],
541
- "dodgerblue": [30, 144, 255],
542
- "firebrick": [178, 34, 34],
543
- "floralwhite": [255, 250, 240],
544
- "forestgreen": [34, 139, 34],
545
- "fuchsia": [255, 0, 255],
546
- "gainsboro": [220, 220, 220],
547
- "ghostwhite": [248, 248, 255],
548
- "gold": [255, 215, 0],
549
- "goldenrod": [218, 165, 32],
550
- "gray": [128, 128, 128],
551
- "green": [0, 128, 0],
552
- "greenyellow": [173, 255, 47],
553
- "grey": [128, 128, 128],
554
- "honeydew": [240, 255, 240],
555
- "hotpink": [255, 105, 180],
556
- "indianred": [205, 92, 92],
557
- "indigo": [75, 0, 130],
558
- "ivory": [255, 255, 240],
559
- "khaki": [240, 230, 140],
560
- "lavender": [230, 230, 250],
561
- "lavenderblush": [255, 240, 245],
562
- "lawngreen": [124, 252, 0],
563
- "lemonchiffon": [255, 250, 205],
564
- "lightblue": [173, 216, 230],
565
- "lightcoral": [240, 128, 128],
566
- "lightcyan": [224, 255, 255],
567
- "lightgoldenrodyellow": [250, 250, 210],
568
- "lightgray": [211, 211, 211],
569
- "lightgreen": [144, 238, 144],
570
- "lightgrey": [211, 211, 211],
571
- "lightpink": [255, 182, 193],
572
- "lightsalmon": [255, 160, 122],
573
- "lightseagreen": [32, 178, 170],
574
- "lightskyblue": [135, 206, 250],
575
- "lightslategray": [119, 136, 153],
576
- "lightslategrey": [119, 136, 153],
577
- "lightsteelblue": [176, 196, 222],
578
- "lightyellow": [255, 255, 224],
579
- "lime": [0, 255, 0],
580
- "limegreen": [50, 205, 50],
581
- "linen": [250, 240, 230],
582
- "magenta": [255, 0, 255],
583
- "maroon": [128, 0, 0],
584
- "mediumaquamarine": [102, 205, 170],
585
- "mediumblue": [0, 0, 205],
586
- "mediumorchid": [186, 85, 211],
587
- "mediumpurple": [147, 112, 219],
588
- "mediumseagreen": [60, 179, 113],
589
- "mediumslateblue": [123, 104, 238],
590
- "mediumspringgreen": [0, 250, 154],
591
- "mediumturquoise": [72, 209, 204],
592
- "mediumvioletred": [199, 21, 133],
593
- "midnightblue": [25, 25, 112],
594
- "mintcream": [245, 255, 250],
595
- "mistyrose": [255, 228, 225],
596
- "moccasin": [255, 228, 181],
597
- "navajowhite": [255, 222, 173],
598
- "navy": [0, 0, 128],
599
- "oldlace": [253, 245, 230],
600
- "olive": [128, 128, 0],
601
- "olivedrab": [107, 142, 35],
602
- "orange": [255, 165, 0],
603
- "orangered": [255, 69, 0],
604
- "orchid": [218, 112, 214],
605
- "palegoldenrod": [238, 232, 170],
606
- "palegreen": [152, 251, 152],
607
- "paleturquoise": [175, 238, 238],
608
- "palevioletred": [219, 112, 147],
609
- "papayawhip": [255, 239, 213],
610
- "peachpuff": [255, 218, 185],
611
- "peru": [205, 133, 63],
612
- "pink": [255, 192, 203],
613
- "plum": [221, 160, 221],
614
- "powderblue": [176, 224, 230],
615
- "purple": [128, 0, 128],
616
- "rebeccapurple": [102, 51, 153],
617
- "red": [255, 0, 0],
618
- "rosybrown": [188, 143, 143],
619
- "royalblue": [65, 105, 225],
620
- "saddlebrown": [139, 69, 19],
621
- "salmon": [250, 128, 114],
622
- "sandybrown": [244, 164, 96],
623
- "seagreen": [46, 139, 87],
624
- "seashell": [255, 245, 238],
625
- "sienna": [160, 82, 45],
626
- "silver": [192, 192, 192],
627
- "skyblue": [135, 206, 235],
628
- "slateblue": [106, 90, 205],
629
- "slategray": [112, 128, 144],
630
- "slategrey": [112, 128, 144],
631
- "snow": [255, 250, 250],
632
- "springgreen": [0, 255, 127],
633
- "steelblue": [70, 130, 180],
634
- "tan": [210, 180, 140],
635
- "teal": [0, 128, 128],
636
- "thistle": [216, 191, 216],
637
- "tomato": [255, 99, 71],
638
- "turquoise": [64, 224, 208],
639
- "violet": [238, 130, 238],
640
- "wheat": [245, 222, 179],
641
- "white": [255, 255, 255],
642
- "whitesmoke": [245, 245, 245],
643
- "yellow": [255, 255, 0],
644
- "yellowgreen": [154, 205, 50]
645
- };
646
- return colorName;
647
- }
648
-
649
- /* MIT license */
650
-
651
- var hasRequiredConversions;
652
-
653
- function requireConversions () {
654
- if (hasRequiredConversions) return conversions.exports;
655
- hasRequiredConversions = 1;
656
- var cssKeywords = requireColorName();
657
-
658
- // NOTE: conversions should only return primitive values (i.e. arrays, or
659
- // values that give correct `typeof` results).
660
- // do not use box values types (i.e. Number(), String(), etc.)
661
-
662
- var reverseKeywords = {};
663
- for (var key in cssKeywords) {
664
- if (cssKeywords.hasOwnProperty(key)) {
665
- reverseKeywords[cssKeywords[key]] = key;
666
- }
667
- }
668
-
669
- var convert = conversions.exports = {
670
- rgb: {channels: 3, labels: 'rgb'},
671
- hsl: {channels: 3, labels: 'hsl'},
672
- hsv: {channels: 3, labels: 'hsv'},
673
- hwb: {channels: 3, labels: 'hwb'},
674
- cmyk: {channels: 4, labels: 'cmyk'},
675
- xyz: {channels: 3, labels: 'xyz'},
676
- lab: {channels: 3, labels: 'lab'},
677
- lch: {channels: 3, labels: 'lch'},
678
- hex: {channels: 1, labels: ['hex']},
679
- keyword: {channels: 1, labels: ['keyword']},
680
- ansi16: {channels: 1, labels: ['ansi16']},
681
- ansi256: {channels: 1, labels: ['ansi256']},
682
- hcg: {channels: 3, labels: ['h', 'c', 'g']},
683
- apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
684
- gray: {channels: 1, labels: ['gray']}
685
- };
686
-
687
- // hide .channels and .labels properties
688
- for (var model in convert) {
689
- if (convert.hasOwnProperty(model)) {
690
- if (!('channels' in convert[model])) {
691
- throw new Error('missing channels property: ' + model);
692
- }
693
-
694
- if (!('labels' in convert[model])) {
695
- throw new Error('missing channel labels property: ' + model);
696
- }
697
-
698
- if (convert[model].labels.length !== convert[model].channels) {
699
- throw new Error('channel and label counts mismatch: ' + model);
700
- }
701
-
702
- var channels = convert[model].channels;
703
- var labels = convert[model].labels;
704
- delete convert[model].channels;
705
- delete convert[model].labels;
706
- Object.defineProperty(convert[model], 'channels', {value: channels});
707
- Object.defineProperty(convert[model], 'labels', {value: labels});
708
- }
709
- }
710
-
711
- convert.rgb.hsl = function (rgb) {
712
- var r = rgb[0] / 255;
713
- var g = rgb[1] / 255;
714
- var b = rgb[2] / 255;
715
- var min = Math.min(r, g, b);
716
- var max = Math.max(r, g, b);
717
- var delta = max - min;
718
- var h;
719
- var s;
720
- var l;
721
-
722
- if (max === min) {
723
- h = 0;
724
- } else if (r === max) {
725
- h = (g - b) / delta;
726
- } else if (g === max) {
727
- h = 2 + (b - r) / delta;
728
- } else if (b === max) {
729
- h = 4 + (r - g) / delta;
730
- }
731
-
732
- h = Math.min(h * 60, 360);
733
-
734
- if (h < 0) {
735
- h += 360;
736
- }
737
-
738
- l = (min + max) / 2;
739
-
740
- if (max === min) {
741
- s = 0;
742
- } else if (l <= 0.5) {
743
- s = delta / (max + min);
744
- } else {
745
- s = delta / (2 - max - min);
746
- }
747
-
748
- return [h, s * 100, l * 100];
749
- };
750
-
751
- convert.rgb.hsv = function (rgb) {
752
- var rdif;
753
- var gdif;
754
- var bdif;
755
- var h;
756
- var s;
757
-
758
- var r = rgb[0] / 255;
759
- var g = rgb[1] / 255;
760
- var b = rgb[2] / 255;
761
- var v = Math.max(r, g, b);
762
- var diff = v - Math.min(r, g, b);
763
- var diffc = function (c) {
764
- return (v - c) / 6 / diff + 1 / 2;
765
- };
766
-
767
- if (diff === 0) {
768
- h = s = 0;
769
- } else {
770
- s = diff / v;
771
- rdif = diffc(r);
772
- gdif = diffc(g);
773
- bdif = diffc(b);
774
-
775
- if (r === v) {
776
- h = bdif - gdif;
777
- } else if (g === v) {
778
- h = (1 / 3) + rdif - bdif;
779
- } else if (b === v) {
780
- h = (2 / 3) + gdif - rdif;
781
- }
782
- if (h < 0) {
783
- h += 1;
784
- } else if (h > 1) {
785
- h -= 1;
786
- }
787
- }
788
-
789
- return [
790
- h * 360,
791
- s * 100,
792
- v * 100
793
- ];
794
- };
795
-
796
- convert.rgb.hwb = function (rgb) {
797
- var r = rgb[0];
798
- var g = rgb[1];
799
- var b = rgb[2];
800
- var h = convert.rgb.hsl(rgb)[0];
801
- var w = 1 / 255 * Math.min(r, Math.min(g, b));
802
-
803
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
804
-
805
- return [h, w * 100, b * 100];
806
- };
807
-
808
- convert.rgb.cmyk = function (rgb) {
809
- var r = rgb[0] / 255;
810
- var g = rgb[1] / 255;
811
- var b = rgb[2] / 255;
812
- var c;
813
- var m;
814
- var y;
815
- var k;
816
-
817
- k = Math.min(1 - r, 1 - g, 1 - b);
818
- c = (1 - r - k) / (1 - k) || 0;
819
- m = (1 - g - k) / (1 - k) || 0;
820
- y = (1 - b - k) / (1 - k) || 0;
821
-
822
- return [c * 100, m * 100, y * 100, k * 100];
823
- };
824
-
825
- /**
826
- * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
827
- * */
828
- function comparativeDistance(x, y) {
829
- return (
830
- Math.pow(x[0] - y[0], 2) +
831
- Math.pow(x[1] - y[1], 2) +
832
- Math.pow(x[2] - y[2], 2)
833
- );
834
- }
835
-
836
- convert.rgb.keyword = function (rgb) {
837
- var reversed = reverseKeywords[rgb];
838
- if (reversed) {
839
- return reversed;
840
- }
841
-
842
- var currentClosestDistance = Infinity;
843
- var currentClosestKeyword;
844
-
845
- for (var keyword in cssKeywords) {
846
- if (cssKeywords.hasOwnProperty(keyword)) {
847
- var value = cssKeywords[keyword];
848
-
849
- // Compute comparative distance
850
- var distance = comparativeDistance(rgb, value);
851
-
852
- // Check if its less, if so set as closest
853
- if (distance < currentClosestDistance) {
854
- currentClosestDistance = distance;
855
- currentClosestKeyword = keyword;
856
- }
857
- }
858
- }
859
-
860
- return currentClosestKeyword;
861
- };
862
-
863
- convert.keyword.rgb = function (keyword) {
864
- return cssKeywords[keyword];
865
- };
866
-
867
- convert.rgb.xyz = function (rgb) {
868
- var r = rgb[0] / 255;
869
- var g = rgb[1] / 255;
870
- var b = rgb[2] / 255;
871
-
872
- // assume sRGB
873
- r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
874
- g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
875
- b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
876
-
877
- var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
878
- var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
879
- var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
880
-
881
- return [x * 100, y * 100, z * 100];
882
- };
883
-
884
- convert.rgb.lab = function (rgb) {
885
- var xyz = convert.rgb.xyz(rgb);
886
- var x = xyz[0];
887
- var y = xyz[1];
888
- var z = xyz[2];
889
- var l;
890
- var a;
891
- var b;
892
-
893
- x /= 95.047;
894
- y /= 100;
895
- z /= 108.883;
896
-
897
- x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
898
- y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
899
- z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
900
-
901
- l = (116 * y) - 16;
902
- a = 500 * (x - y);
903
- b = 200 * (y - z);
904
-
905
- return [l, a, b];
906
- };
907
-
908
- convert.hsl.rgb = function (hsl) {
909
- var h = hsl[0] / 360;
910
- var s = hsl[1] / 100;
911
- var l = hsl[2] / 100;
912
- var t1;
913
- var t2;
914
- var t3;
915
- var rgb;
916
- var val;
917
-
918
- if (s === 0) {
919
- val = l * 255;
920
- return [val, val, val];
921
- }
922
-
923
- if (l < 0.5) {
924
- t2 = l * (1 + s);
925
- } else {
926
- t2 = l + s - l * s;
927
- }
928
-
929
- t1 = 2 * l - t2;
930
-
931
- rgb = [0, 0, 0];
932
- for (var i = 0; i < 3; i++) {
933
- t3 = h + 1 / 3 * -(i - 1);
934
- if (t3 < 0) {
935
- t3++;
936
- }
937
- if (t3 > 1) {
938
- t3--;
939
- }
940
-
941
- if (6 * t3 < 1) {
942
- val = t1 + (t2 - t1) * 6 * t3;
943
- } else if (2 * t3 < 1) {
944
- val = t2;
945
- } else if (3 * t3 < 2) {
946
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
947
- } else {
948
- val = t1;
949
- }
950
-
951
- rgb[i] = val * 255;
952
- }
953
-
954
- return rgb;
955
- };
956
-
957
- convert.hsl.hsv = function (hsl) {
958
- var h = hsl[0];
959
- var s = hsl[1] / 100;
960
- var l = hsl[2] / 100;
961
- var smin = s;
962
- var lmin = Math.max(l, 0.01);
963
- var sv;
964
- var v;
965
-
966
- l *= 2;
967
- s *= (l <= 1) ? l : 2 - l;
968
- smin *= lmin <= 1 ? lmin : 2 - lmin;
969
- v = (l + s) / 2;
970
- sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
971
-
972
- return [h, sv * 100, v * 100];
973
- };
974
-
975
- convert.hsv.rgb = function (hsv) {
976
- var h = hsv[0] / 60;
977
- var s = hsv[1] / 100;
978
- var v = hsv[2] / 100;
979
- var hi = Math.floor(h) % 6;
980
-
981
- var f = h - Math.floor(h);
982
- var p = 255 * v * (1 - s);
983
- var q = 255 * v * (1 - (s * f));
984
- var t = 255 * v * (1 - (s * (1 - f)));
985
- v *= 255;
986
-
987
- switch (hi) {
988
- case 0:
989
- return [v, t, p];
990
- case 1:
991
- return [q, v, p];
992
- case 2:
993
- return [p, v, t];
994
- case 3:
995
- return [p, q, v];
996
- case 4:
997
- return [t, p, v];
998
- case 5:
999
- return [v, p, q];
1000
- }
1001
- };
1002
-
1003
- convert.hsv.hsl = function (hsv) {
1004
- var h = hsv[0];
1005
- var s = hsv[1] / 100;
1006
- var v = hsv[2] / 100;
1007
- var vmin = Math.max(v, 0.01);
1008
- var lmin;
1009
- var sl;
1010
- var l;
1011
-
1012
- l = (2 - s) * v;
1013
- lmin = (2 - s) * vmin;
1014
- sl = s * vmin;
1015
- sl /= (lmin <= 1) ? lmin : 2 - lmin;
1016
- sl = sl || 0;
1017
- l /= 2;
1018
-
1019
- return [h, sl * 100, l * 100];
1020
- };
1021
-
1022
- // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
1023
- convert.hwb.rgb = function (hwb) {
1024
- var h = hwb[0] / 360;
1025
- var wh = hwb[1] / 100;
1026
- var bl = hwb[2] / 100;
1027
- var ratio = wh + bl;
1028
- var i;
1029
- var v;
1030
- var f;
1031
- var n;
1032
-
1033
- // wh + bl cant be > 1
1034
- if (ratio > 1) {
1035
- wh /= ratio;
1036
- bl /= ratio;
1037
- }
1038
-
1039
- i = Math.floor(6 * h);
1040
- v = 1 - bl;
1041
- f = 6 * h - i;
1042
-
1043
- if ((i & 0x01) !== 0) {
1044
- f = 1 - f;
1045
- }
1046
-
1047
- n = wh + f * (v - wh); // linear interpolation
1048
-
1049
- var r;
1050
- var g;
1051
- var b;
1052
- switch (i) {
1053
- default:
1054
- case 6:
1055
- case 0: r = v; g = n; b = wh; break;
1056
- case 1: r = n; g = v; b = wh; break;
1057
- case 2: r = wh; g = v; b = n; break;
1058
- case 3: r = wh; g = n; b = v; break;
1059
- case 4: r = n; g = wh; b = v; break;
1060
- case 5: r = v; g = wh; b = n; break;
1061
- }
1062
-
1063
- return [r * 255, g * 255, b * 255];
1064
- };
1065
-
1066
- convert.cmyk.rgb = function (cmyk) {
1067
- var c = cmyk[0] / 100;
1068
- var m = cmyk[1] / 100;
1069
- var y = cmyk[2] / 100;
1070
- var k = cmyk[3] / 100;
1071
- var r;
1072
- var g;
1073
- var b;
1074
-
1075
- r = 1 - Math.min(1, c * (1 - k) + k);
1076
- g = 1 - Math.min(1, m * (1 - k) + k);
1077
- b = 1 - Math.min(1, y * (1 - k) + k);
1078
-
1079
- return [r * 255, g * 255, b * 255];
1080
- };
1081
-
1082
- convert.xyz.rgb = function (xyz) {
1083
- var x = xyz[0] / 100;
1084
- var y = xyz[1] / 100;
1085
- var z = xyz[2] / 100;
1086
- var r;
1087
- var g;
1088
- var b;
1089
-
1090
- r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
1091
- g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
1092
- b = (x * 0.0557) + (y * -0.204) + (z * 1.0570);
1093
-
1094
- // assume sRGB
1095
- r = r > 0.0031308
1096
- ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
1097
- : r * 12.92;
1098
-
1099
- g = g > 0.0031308
1100
- ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
1101
- : g * 12.92;
1102
-
1103
- b = b > 0.0031308
1104
- ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
1105
- : b * 12.92;
1106
-
1107
- r = Math.min(Math.max(0, r), 1);
1108
- g = Math.min(Math.max(0, g), 1);
1109
- b = Math.min(Math.max(0, b), 1);
1110
-
1111
- return [r * 255, g * 255, b * 255];
1112
- };
1113
-
1114
- convert.xyz.lab = function (xyz) {
1115
- var x = xyz[0];
1116
- var y = xyz[1];
1117
- var z = xyz[2];
1118
- var l;
1119
- var a;
1120
- var b;
1121
-
1122
- x /= 95.047;
1123
- y /= 100;
1124
- z /= 108.883;
1125
-
1126
- x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
1127
- y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
1128
- z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
1129
-
1130
- l = (116 * y) - 16;
1131
- a = 500 * (x - y);
1132
- b = 200 * (y - z);
1133
-
1134
- return [l, a, b];
1135
- };
1136
-
1137
- convert.lab.xyz = function (lab) {
1138
- var l = lab[0];
1139
- var a = lab[1];
1140
- var b = lab[2];
1141
- var x;
1142
- var y;
1143
- var z;
1144
-
1145
- y = (l + 16) / 116;
1146
- x = a / 500 + y;
1147
- z = y - b / 200;
1148
-
1149
- var y2 = Math.pow(y, 3);
1150
- var x2 = Math.pow(x, 3);
1151
- var z2 = Math.pow(z, 3);
1152
- y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
1153
- x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
1154
- z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
1155
-
1156
- x *= 95.047;
1157
- y *= 100;
1158
- z *= 108.883;
1159
-
1160
- return [x, y, z];
1161
- };
1162
-
1163
- convert.lab.lch = function (lab) {
1164
- var l = lab[0];
1165
- var a = lab[1];
1166
- var b = lab[2];
1167
- var hr;
1168
- var h;
1169
- var c;
1170
-
1171
- hr = Math.atan2(b, a);
1172
- h = hr * 360 / 2 / Math.PI;
1173
-
1174
- if (h < 0) {
1175
- h += 360;
1176
- }
1177
-
1178
- c = Math.sqrt(a * a + b * b);
1179
-
1180
- return [l, c, h];
1181
- };
1182
-
1183
- convert.lch.lab = function (lch) {
1184
- var l = lch[0];
1185
- var c = lch[1];
1186
- var h = lch[2];
1187
- var a;
1188
- var b;
1189
- var hr;
1190
-
1191
- hr = h / 360 * 2 * Math.PI;
1192
- a = c * Math.cos(hr);
1193
- b = c * Math.sin(hr);
1194
-
1195
- return [l, a, b];
1196
- };
1197
-
1198
- convert.rgb.ansi16 = function (args) {
1199
- var r = args[0];
1200
- var g = args[1];
1201
- var b = args[2];
1202
- var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
1203
-
1204
- value = Math.round(value / 50);
1205
-
1206
- if (value === 0) {
1207
- return 30;
1208
- }
1209
-
1210
- var ansi = 30
1211
- + ((Math.round(b / 255) << 2)
1212
- | (Math.round(g / 255) << 1)
1213
- | Math.round(r / 255));
1214
-
1215
- if (value === 2) {
1216
- ansi += 60;
1217
- }
1218
-
1219
- return ansi;
1220
- };
1221
-
1222
- convert.hsv.ansi16 = function (args) {
1223
- // optimization here; we already know the value and don't need to get
1224
- // it converted for us.
1225
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
1226
- };
1227
-
1228
- convert.rgb.ansi256 = function (args) {
1229
- var r = args[0];
1230
- var g = args[1];
1231
- var b = args[2];
1232
-
1233
- // we use the extended greyscale palette here, with the exception of
1234
- // black and white. normal palette only has 4 greyscale shades.
1235
- if (r === g && g === b) {
1236
- if (r < 8) {
1237
- return 16;
1238
- }
1239
-
1240
- if (r > 248) {
1241
- return 231;
1242
- }
1243
-
1244
- return Math.round(((r - 8) / 247) * 24) + 232;
1245
- }
1246
-
1247
- var ansi = 16
1248
- + (36 * Math.round(r / 255 * 5))
1249
- + (6 * Math.round(g / 255 * 5))
1250
- + Math.round(b / 255 * 5);
1251
-
1252
- return ansi;
1253
- };
1254
-
1255
- convert.ansi16.rgb = function (args) {
1256
- var color = args % 10;
1257
-
1258
- // handle greyscale
1259
- if (color === 0 || color === 7) {
1260
- if (args > 50) {
1261
- color += 3.5;
1262
- }
1263
-
1264
- color = color / 10.5 * 255;
1265
-
1266
- return [color, color, color];
1267
- }
1268
-
1269
- var mult = (~~(args > 50) + 1) * 0.5;
1270
- var r = ((color & 1) * mult) * 255;
1271
- var g = (((color >> 1) & 1) * mult) * 255;
1272
- var b = (((color >> 2) & 1) * mult) * 255;
1273
-
1274
- return [r, g, b];
1275
- };
1276
-
1277
- convert.ansi256.rgb = function (args) {
1278
- // handle greyscale
1279
- if (args >= 232) {
1280
- var c = (args - 232) * 10 + 8;
1281
- return [c, c, c];
1282
- }
1283
-
1284
- args -= 16;
1285
-
1286
- var rem;
1287
- var r = Math.floor(args / 36) / 5 * 255;
1288
- var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1289
- var b = (rem % 6) / 5 * 255;
1290
-
1291
- return [r, g, b];
1292
- };
1293
-
1294
- convert.rgb.hex = function (args) {
1295
- var integer = ((Math.round(args[0]) & 0xFF) << 16)
1296
- + ((Math.round(args[1]) & 0xFF) << 8)
1297
- + (Math.round(args[2]) & 0xFF);
1298
-
1299
- var string = integer.toString(16).toUpperCase();
1300
- return '000000'.substring(string.length) + string;
1301
- };
1302
-
1303
- convert.hex.rgb = function (args) {
1304
- var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1305
- if (!match) {
1306
- return [0, 0, 0];
1307
- }
1308
-
1309
- var colorString = match[0];
1310
-
1311
- if (match[0].length === 3) {
1312
- colorString = colorString.split('').map(function (char) {
1313
- return char + char;
1314
- }).join('');
1315
- }
1316
-
1317
- var integer = parseInt(colorString, 16);
1318
- var r = (integer >> 16) & 0xFF;
1319
- var g = (integer >> 8) & 0xFF;
1320
- var b = integer & 0xFF;
1321
-
1322
- return [r, g, b];
1323
- };
1324
-
1325
- convert.rgb.hcg = function (rgb) {
1326
- var r = rgb[0] / 255;
1327
- var g = rgb[1] / 255;
1328
- var b = rgb[2] / 255;
1329
- var max = Math.max(Math.max(r, g), b);
1330
- var min = Math.min(Math.min(r, g), b);
1331
- var chroma = (max - min);
1332
- var grayscale;
1333
- var hue;
1334
-
1335
- if (chroma < 1) {
1336
- grayscale = min / (1 - chroma);
1337
- } else {
1338
- grayscale = 0;
1339
- }
1340
-
1341
- if (chroma <= 0) {
1342
- hue = 0;
1343
- } else
1344
- if (max === r) {
1345
- hue = ((g - b) / chroma) % 6;
1346
- } else
1347
- if (max === g) {
1348
- hue = 2 + (b - r) / chroma;
1349
- } else {
1350
- hue = 4 + (r - g) / chroma + 4;
1351
- }
1352
-
1353
- hue /= 6;
1354
- hue %= 1;
1355
-
1356
- return [hue * 360, chroma * 100, grayscale * 100];
1357
- };
1358
-
1359
- convert.hsl.hcg = function (hsl) {
1360
- var s = hsl[1] / 100;
1361
- var l = hsl[2] / 100;
1362
- var c = 1;
1363
- var f = 0;
1364
-
1365
- if (l < 0.5) {
1366
- c = 2.0 * s * l;
1367
- } else {
1368
- c = 2.0 * s * (1.0 - l);
1369
- }
1370
-
1371
- if (c < 1.0) {
1372
- f = (l - 0.5 * c) / (1.0 - c);
1373
- }
1374
-
1375
- return [hsl[0], c * 100, f * 100];
1376
- };
1377
-
1378
- convert.hsv.hcg = function (hsv) {
1379
- var s = hsv[1] / 100;
1380
- var v = hsv[2] / 100;
1381
-
1382
- var c = s * v;
1383
- var f = 0;
1384
-
1385
- if (c < 1.0) {
1386
- f = (v - c) / (1 - c);
1387
- }
1388
-
1389
- return [hsv[0], c * 100, f * 100];
1390
- };
1391
-
1392
- convert.hcg.rgb = function (hcg) {
1393
- var h = hcg[0] / 360;
1394
- var c = hcg[1] / 100;
1395
- var g = hcg[2] / 100;
1396
-
1397
- if (c === 0.0) {
1398
- return [g * 255, g * 255, g * 255];
1399
- }
1400
-
1401
- var pure = [0, 0, 0];
1402
- var hi = (h % 1) * 6;
1403
- var v = hi % 1;
1404
- var w = 1 - v;
1405
- var mg = 0;
1406
-
1407
- switch (Math.floor(hi)) {
1408
- case 0:
1409
- pure[0] = 1; pure[1] = v; pure[2] = 0; break;
1410
- case 1:
1411
- pure[0] = w; pure[1] = 1; pure[2] = 0; break;
1412
- case 2:
1413
- pure[0] = 0; pure[1] = 1; pure[2] = v; break;
1414
- case 3:
1415
- pure[0] = 0; pure[1] = w; pure[2] = 1; break;
1416
- case 4:
1417
- pure[0] = v; pure[1] = 0; pure[2] = 1; break;
1418
- default:
1419
- pure[0] = 1; pure[1] = 0; pure[2] = w;
1420
- }
1421
-
1422
- mg = (1.0 - c) * g;
1423
-
1424
- return [
1425
- (c * pure[0] + mg) * 255,
1426
- (c * pure[1] + mg) * 255,
1427
- (c * pure[2] + mg) * 255
1428
- ];
1429
- };
1430
-
1431
- convert.hcg.hsv = function (hcg) {
1432
- var c = hcg[1] / 100;
1433
- var g = hcg[2] / 100;
1434
-
1435
- var v = c + g * (1.0 - c);
1436
- var f = 0;
1437
-
1438
- if (v > 0.0) {
1439
- f = c / v;
1440
- }
1441
-
1442
- return [hcg[0], f * 100, v * 100];
1443
- };
1444
-
1445
- convert.hcg.hsl = function (hcg) {
1446
- var c = hcg[1] / 100;
1447
- var g = hcg[2] / 100;
1448
-
1449
- var l = g * (1.0 - c) + 0.5 * c;
1450
- var s = 0;
1451
-
1452
- if (l > 0.0 && l < 0.5) {
1453
- s = c / (2 * l);
1454
- } else
1455
- if (l >= 0.5 && l < 1.0) {
1456
- s = c / (2 * (1 - l));
1457
- }
1458
-
1459
- return [hcg[0], s * 100, l * 100];
1460
- };
1461
-
1462
- convert.hcg.hwb = function (hcg) {
1463
- var c = hcg[1] / 100;
1464
- var g = hcg[2] / 100;
1465
- var v = c + g * (1.0 - c);
1466
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
1467
- };
1468
-
1469
- convert.hwb.hcg = function (hwb) {
1470
- var w = hwb[1] / 100;
1471
- var b = hwb[2] / 100;
1472
- var v = 1 - b;
1473
- var c = v - w;
1474
- var g = 0;
1475
-
1476
- if (c < 1) {
1477
- g = (v - c) / (1 - c);
1478
- }
1479
-
1480
- return [hwb[0], c * 100, g * 100];
1481
- };
1482
-
1483
- convert.apple.rgb = function (apple) {
1484
- return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
1485
- };
1486
-
1487
- convert.rgb.apple = function (rgb) {
1488
- return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
1489
- };
1490
-
1491
- convert.gray.rgb = function (args) {
1492
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1493
- };
1494
-
1495
- convert.gray.hsl = convert.gray.hsv = function (args) {
1496
- return [0, 0, args[0]];
1497
- };
1498
-
1499
- convert.gray.hwb = function (gray) {
1500
- return [0, 100, gray[0]];
1501
- };
1502
-
1503
- convert.gray.cmyk = function (gray) {
1504
- return [0, 0, 0, gray[0]];
1505
- };
1506
-
1507
- convert.gray.lab = function (gray) {
1508
- return [gray[0], 0, 0];
1509
- };
1510
-
1511
- convert.gray.hex = function (gray) {
1512
- var val = Math.round(gray[0] / 100 * 255) & 0xFF;
1513
- var integer = (val << 16) + (val << 8) + val;
1514
-
1515
- var string = integer.toString(16).toUpperCase();
1516
- return '000000'.substring(string.length) + string;
1517
- };
1518
-
1519
- convert.rgb.gray = function (rgb) {
1520
- var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1521
- return [val / 255 * 100];
1522
- };
1523
- return conversions.exports;
1524
- }
1525
-
1526
- var route;
1527
- var hasRequiredRoute;
1528
-
1529
- function requireRoute () {
1530
- if (hasRequiredRoute) return route;
1531
- hasRequiredRoute = 1;
1532
- var conversions = requireConversions();
1533
-
1534
- /*
1535
- this function routes a model to all other models.
1536
-
1537
- all functions that are routed have a property `.conversion` attached
1538
- to the returned synthetic function. This property is an array
1539
- of strings, each with the steps in between the 'from' and 'to'
1540
- color models (inclusive).
1541
-
1542
- conversions that are not possible simply are not included.
1543
- */
1544
-
1545
- function buildGraph() {
1546
- var graph = {};
1547
- // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1548
- var models = Object.keys(conversions);
1549
-
1550
- for (var len = models.length, i = 0; i < len; i++) {
1551
- graph[models[i]] = {
1552
- // http://jsperf.com/1-vs-infinity
1553
- // micro-opt, but this is simple.
1554
- distance: -1,
1555
- parent: null
1556
- };
1557
- }
1558
-
1559
- return graph;
1560
- }
1561
-
1562
- // https://en.wikipedia.org/wiki/Breadth-first_search
1563
- function deriveBFS(fromModel) {
1564
- var graph = buildGraph();
1565
- var queue = [fromModel]; // unshift -> queue -> pop
1566
-
1567
- graph[fromModel].distance = 0;
1568
-
1569
- while (queue.length) {
1570
- var current = queue.pop();
1571
- var adjacents = Object.keys(conversions[current]);
1572
-
1573
- for (var len = adjacents.length, i = 0; i < len; i++) {
1574
- var adjacent = adjacents[i];
1575
- var node = graph[adjacent];
1576
-
1577
- if (node.distance === -1) {
1578
- node.distance = graph[current].distance + 1;
1579
- node.parent = current;
1580
- queue.unshift(adjacent);
1581
- }
1582
- }
1583
- }
1584
-
1585
- return graph;
1586
- }
1587
-
1588
- function link(from, to) {
1589
- return function (args) {
1590
- return to(from(args));
1591
- };
1592
- }
1593
-
1594
- function wrapConversion(toModel, graph) {
1595
- var path = [graph[toModel].parent, toModel];
1596
- var fn = conversions[graph[toModel].parent][toModel];
1597
-
1598
- var cur = graph[toModel].parent;
1599
- while (graph[cur].parent) {
1600
- path.unshift(graph[cur].parent);
1601
- fn = link(conversions[graph[cur].parent][cur], fn);
1602
- cur = graph[cur].parent;
1603
- }
1604
-
1605
- fn.conversion = path;
1606
- return fn;
1607
- }
1608
-
1609
- route = function (fromModel) {
1610
- var graph = deriveBFS(fromModel);
1611
- var conversion = {};
1612
-
1613
- var models = Object.keys(graph);
1614
- for (var len = models.length, i = 0; i < len; i++) {
1615
- var toModel = models[i];
1616
- var node = graph[toModel];
1617
-
1618
- if (node.parent === null) {
1619
- // no possible conversion, or this node is the source model.
1620
- continue;
1621
- }
1622
-
1623
- conversion[toModel] = wrapConversion(toModel, graph);
1624
- }
1625
-
1626
- return conversion;
1627
- };
1628
- return route;
1629
- }
1630
-
1631
- var colorConvert;
1632
- var hasRequiredColorConvert;
1633
-
1634
- function requireColorConvert () {
1635
- if (hasRequiredColorConvert) return colorConvert;
1636
- hasRequiredColorConvert = 1;
1637
- var conversions = requireConversions();
1638
- var route = requireRoute();
1639
-
1640
- var convert = {};
1641
-
1642
- var models = Object.keys(conversions);
1643
-
1644
- function wrapRaw(fn) {
1645
- var wrappedFn = function (args) {
1646
- if (args === undefined || args === null) {
1647
- return args;
1648
- }
1649
-
1650
- if (arguments.length > 1) {
1651
- args = Array.prototype.slice.call(arguments);
1652
- }
1653
-
1654
- return fn(args);
1655
- };
1656
-
1657
- // preserve .conversion property if there is one
1658
- if ('conversion' in fn) {
1659
- wrappedFn.conversion = fn.conversion;
1660
- }
1661
-
1662
- return wrappedFn;
1663
- }
1664
-
1665
- function wrapRounded(fn) {
1666
- var wrappedFn = function (args) {
1667
- if (args === undefined || args === null) {
1668
- return args;
1669
- }
1670
-
1671
- if (arguments.length > 1) {
1672
- args = Array.prototype.slice.call(arguments);
1673
- }
1674
-
1675
- var result = fn(args);
1676
-
1677
- // we're assuming the result is an array here.
1678
- // see notice in conversions.js; don't use box types
1679
- // in conversion functions.
1680
- if (typeof result === 'object') {
1681
- for (var len = result.length, i = 0; i < len; i++) {
1682
- result[i] = Math.round(result[i]);
1683
- }
1684
- }
1685
-
1686
- return result;
1687
- };
1688
-
1689
- // preserve .conversion property if there is one
1690
- if ('conversion' in fn) {
1691
- wrappedFn.conversion = fn.conversion;
1692
- }
1693
-
1694
- return wrappedFn;
1695
- }
1696
-
1697
- models.forEach(function (fromModel) {
1698
- convert[fromModel] = {};
1699
-
1700
- Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
1701
- Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
1702
-
1703
- var routes = route(fromModel);
1704
- var routeModels = Object.keys(routes);
1705
-
1706
- routeModels.forEach(function (toModel) {
1707
- var fn = routes[toModel];
1708
-
1709
- convert[fromModel][toModel] = wrapRounded(fn);
1710
- convert[fromModel][toModel].raw = wrapRaw(fn);
1711
- });
1712
- });
1713
-
1714
- colorConvert = convert;
1715
- return colorConvert;
1716
- }
1717
-
1718
- var color;
1719
- var hasRequiredColor;
1720
-
1721
- function requireColor () {
1722
- if (hasRequiredColor) return color;
1723
- hasRequiredColor = 1;
1724
-
1725
- var colorString = requireColorString();
1726
- var convert = requireColorConvert();
1727
-
1728
- var _slice = [].slice;
1729
-
1730
- var skippedModels = [
1731
- // to be honest, I don't really feel like keyword belongs in color convert, but eh.
1732
- 'keyword',
1733
-
1734
- // gray conflicts with some method names, and has its own method defined.
1735
- 'gray',
1736
-
1737
- // shouldn't really be in color-convert either...
1738
- 'hex'
1739
- ];
1740
-
1741
- var hashedModelKeys = {};
1742
- Object.keys(convert).forEach(function (model) {
1743
- hashedModelKeys[_slice.call(convert[model].labels).sort().join('')] = model;
1744
- });
1745
-
1746
- var limiters = {};
1747
-
1748
- function Color(obj, model) {
1749
- if (!(this instanceof Color)) {
1750
- return new Color(obj, model);
1751
- }
1752
-
1753
- if (model && model in skippedModels) {
1754
- model = null;
1755
- }
1756
-
1757
- if (model && !(model in convert)) {
1758
- throw new Error('Unknown model: ' + model);
1759
- }
1760
-
1761
- var i;
1762
- var channels;
1763
-
1764
- if (obj == null) { // eslint-disable-line no-eq-null,eqeqeq
1765
- this.model = 'rgb';
1766
- this.color = [0, 0, 0];
1767
- this.valpha = 1;
1768
- } else if (obj instanceof Color) {
1769
- this.model = obj.model;
1770
- this.color = obj.color.slice();
1771
- this.valpha = obj.valpha;
1772
- } else if (typeof obj === 'string') {
1773
- var result = colorString.get(obj);
1774
- if (result === null) {
1775
- throw new Error('Unable to parse color from string: ' + obj);
1776
- }
1777
-
1778
- this.model = result.model;
1779
- channels = convert[this.model].channels;
1780
- this.color = result.value.slice(0, channels);
1781
- this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
1782
- } else if (obj.length) {
1783
- this.model = model || 'rgb';
1784
- channels = convert[this.model].channels;
1785
- var newArr = _slice.call(obj, 0, channels);
1786
- this.color = zeroArray(newArr, channels);
1787
- this.valpha = typeof obj[channels] === 'number' ? obj[channels] : 1;
1788
- } else if (typeof obj === 'number') {
1789
- // this is always RGB - can be converted later on.
1790
- obj &= 0xFFFFFF;
1791
- this.model = 'rgb';
1792
- this.color = [
1793
- (obj >> 16) & 0xFF,
1794
- (obj >> 8) & 0xFF,
1795
- obj & 0xFF
1796
- ];
1797
- this.valpha = 1;
1798
- } else {
1799
- this.valpha = 1;
1800
-
1801
- var keys = Object.keys(obj);
1802
- if ('alpha' in obj) {
1803
- keys.splice(keys.indexOf('alpha'), 1);
1804
- this.valpha = typeof obj.alpha === 'number' ? obj.alpha : 0;
1805
- }
1806
-
1807
- var hashedKeys = keys.sort().join('');
1808
- if (!(hashedKeys in hashedModelKeys)) {
1809
- throw new Error('Unable to parse color from object: ' + JSON.stringify(obj));
1810
- }
1811
-
1812
- this.model = hashedModelKeys[hashedKeys];
1813
-
1814
- var labels = convert[this.model].labels;
1815
- var color = [];
1816
- for (i = 0; i < labels.length; i++) {
1817
- color.push(obj[labels[i]]);
1818
- }
1819
-
1820
- this.color = zeroArray(color);
1821
- }
1822
-
1823
- // perform limitations (clamping, etc.)
1824
- if (limiters[this.model]) {
1825
- channels = convert[this.model].channels;
1826
- for (i = 0; i < channels; i++) {
1827
- var limit = limiters[this.model][i];
1828
- if (limit) {
1829
- this.color[i] = limit(this.color[i]);
1830
- }
1831
- }
1832
- }
1833
-
1834
- this.valpha = Math.max(0, Math.min(1, this.valpha));
1835
-
1836
- if (Object.freeze) {
1837
- Object.freeze(this);
1838
- }
1839
- }
1840
-
1841
- Color.prototype = {
1842
- toString: function () {
1843
- return this.string();
1844
- },
1845
-
1846
- toJSON: function () {
1847
- return this[this.model]();
1848
- },
1849
-
1850
- string: function (places) {
1851
- var self = this.model in colorString.to ? this : this.rgb();
1852
- self = self.round(typeof places === 'number' ? places : 1);
1853
- var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
1854
- return colorString.to[self.model](args);
1855
- },
1856
-
1857
- percentString: function (places) {
1858
- var self = this.rgb().round(typeof places === 'number' ? places : 1);
1859
- var args = self.valpha === 1 ? self.color : self.color.concat(this.valpha);
1860
- return colorString.to.rgb.percent(args);
1861
- },
1862
-
1863
- array: function () {
1864
- return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
1865
- },
1866
-
1867
- object: function () {
1868
- var result = {};
1869
- var channels = convert[this.model].channels;
1870
- var labels = convert[this.model].labels;
1871
-
1872
- for (var i = 0; i < channels; i++) {
1873
- result[labels[i]] = this.color[i];
1874
- }
1875
-
1876
- if (this.valpha !== 1) {
1877
- result.alpha = this.valpha;
1878
- }
1879
-
1880
- return result;
1881
- },
1882
-
1883
- unitArray: function () {
1884
- var rgb = this.rgb().color;
1885
- rgb[0] /= 255;
1886
- rgb[1] /= 255;
1887
- rgb[2] /= 255;
1888
-
1889
- if (this.valpha !== 1) {
1890
- rgb.push(this.valpha);
1891
- }
1892
-
1893
- return rgb;
1894
- },
1895
-
1896
- unitObject: function () {
1897
- var rgb = this.rgb().object();
1898
- rgb.r /= 255;
1899
- rgb.g /= 255;
1900
- rgb.b /= 255;
1901
-
1902
- if (this.valpha !== 1) {
1903
- rgb.alpha = this.valpha;
1904
- }
1905
-
1906
- return rgb;
1907
- },
1908
-
1909
- round: function (places) {
1910
- places = Math.max(places || 0, 0);
1911
- return new Color(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
1912
- },
1913
-
1914
- alpha: function (val) {
1915
- if (arguments.length) {
1916
- return new Color(this.color.concat(Math.max(0, Math.min(1, val))), this.model);
1917
- }
1918
-
1919
- return this.valpha;
1920
- },
1921
-
1922
- // rgb
1923
- red: getset('rgb', 0, maxfn(255)),
1924
- green: getset('rgb', 1, maxfn(255)),
1925
- blue: getset('rgb', 2, maxfn(255)),
1926
-
1927
- hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, function (val) { return ((val % 360) + 360) % 360; }), // eslint-disable-line brace-style
1928
-
1929
- saturationl: getset('hsl', 1, maxfn(100)),
1930
- lightness: getset('hsl', 2, maxfn(100)),
1931
-
1932
- saturationv: getset('hsv', 1, maxfn(100)),
1933
- value: getset('hsv', 2, maxfn(100)),
1934
-
1935
- chroma: getset('hcg', 1, maxfn(100)),
1936
- gray: getset('hcg', 2, maxfn(100)),
1937
-
1938
- white: getset('hwb', 1, maxfn(100)),
1939
- wblack: getset('hwb', 2, maxfn(100)),
1940
-
1941
- cyan: getset('cmyk', 0, maxfn(100)),
1942
- magenta: getset('cmyk', 1, maxfn(100)),
1943
- yellow: getset('cmyk', 2, maxfn(100)),
1944
- black: getset('cmyk', 3, maxfn(100)),
1945
-
1946
- x: getset('xyz', 0, maxfn(100)),
1947
- y: getset('xyz', 1, maxfn(100)),
1948
- z: getset('xyz', 2, maxfn(100)),
1949
-
1950
- l: getset('lab', 0, maxfn(100)),
1951
- a: getset('lab', 1),
1952
- b: getset('lab', 2),
1953
-
1954
- keyword: function (val) {
1955
- if (arguments.length) {
1956
- return new Color(val);
1957
- }
1958
-
1959
- return convert[this.model].keyword(this.color);
1960
- },
1961
-
1962
- hex: function (val) {
1963
- if (arguments.length) {
1964
- return new Color(val);
1965
- }
1966
-
1967
- return colorString.to.hex(this.rgb().round().color);
1968
- },
1969
-
1970
- rgbNumber: function () {
1971
- var rgb = this.rgb().color;
1972
- return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
1973
- },
1974
-
1975
- luminosity: function () {
1976
- // http://www.w3.org/TR/WCAG20/#relativeluminancedef
1977
- var rgb = this.rgb().color;
1978
-
1979
- var lum = [];
1980
- for (var i = 0; i < rgb.length; i++) {
1981
- var chan = rgb[i] / 255;
1982
- lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
1983
- }
1984
-
1985
- return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
1986
- },
1987
-
1988
- contrast: function (color2) {
1989
- // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
1990
- var lum1 = this.luminosity();
1991
- var lum2 = color2.luminosity();
1992
-
1993
- if (lum1 > lum2) {
1994
- return (lum1 + 0.05) / (lum2 + 0.05);
1995
- }
1996
-
1997
- return (lum2 + 0.05) / (lum1 + 0.05);
1998
- },
1999
-
2000
- level: function (color2) {
2001
- var contrastRatio = this.contrast(color2);
2002
- if (contrastRatio >= 7.1) {
2003
- return 'AAA';
2004
- }
2005
-
2006
- return (contrastRatio >= 4.5) ? 'AA' : '';
2007
- },
2008
-
2009
- isDark: function () {
2010
- // YIQ equation from http://24ways.org/2010/calculating-color-contrast
2011
- var rgb = this.rgb().color;
2012
- var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
2013
- return yiq < 128;
2014
- },
2015
-
2016
- isLight: function () {
2017
- return !this.isDark();
2018
- },
2019
-
2020
- negate: function () {
2021
- var rgb = this.rgb();
2022
- for (var i = 0; i < 3; i++) {
2023
- rgb.color[i] = 255 - rgb.color[i];
2024
- }
2025
- return rgb;
2026
- },
2027
-
2028
- lighten: function (ratio) {
2029
- var hsl = this.hsl();
2030
- hsl.color[2] += hsl.color[2] * ratio;
2031
- return hsl;
2032
- },
2033
-
2034
- darken: function (ratio) {
2035
- var hsl = this.hsl();
2036
- hsl.color[2] -= hsl.color[2] * ratio;
2037
- return hsl;
2038
- },
2039
-
2040
- saturate: function (ratio) {
2041
- var hsl = this.hsl();
2042
- hsl.color[1] += hsl.color[1] * ratio;
2043
- return hsl;
2044
- },
2045
-
2046
- desaturate: function (ratio) {
2047
- var hsl = this.hsl();
2048
- hsl.color[1] -= hsl.color[1] * ratio;
2049
- return hsl;
2050
- },
2051
-
2052
- whiten: function (ratio) {
2053
- var hwb = this.hwb();
2054
- hwb.color[1] += hwb.color[1] * ratio;
2055
- return hwb;
2056
- },
2057
-
2058
- blacken: function (ratio) {
2059
- var hwb = this.hwb();
2060
- hwb.color[2] += hwb.color[2] * ratio;
2061
- return hwb;
2062
- },
2063
-
2064
- grayscale: function () {
2065
- // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
2066
- var rgb = this.rgb().color;
2067
- var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
2068
- return Color.rgb(val, val, val);
2069
- },
2070
-
2071
- fade: function (ratio) {
2072
- return this.alpha(this.valpha - (this.valpha * ratio));
2073
- },
2074
-
2075
- opaquer: function (ratio) {
2076
- return this.alpha(this.valpha + (this.valpha * ratio));
2077
- },
2078
-
2079
- rotate: function (degrees) {
2080
- var hsl = this.hsl();
2081
- var hue = hsl.color[0];
2082
- hue = (hue + degrees) % 360;
2083
- hue = hue < 0 ? 360 + hue : hue;
2084
- hsl.color[0] = hue;
2085
- return hsl;
2086
- },
2087
-
2088
- mix: function (mixinColor, weight) {
2089
- // ported from sass implementation in C
2090
- // https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
2091
- if (!mixinColor || !mixinColor.rgb) {
2092
- throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
2093
- }
2094
- var color1 = mixinColor.rgb();
2095
- var color2 = this.rgb();
2096
- var p = weight === undefined ? 0.5 : weight;
2097
-
2098
- var w = 2 * p - 1;
2099
- var a = color1.alpha() - color2.alpha();
2100
-
2101
- var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
2102
- var w2 = 1 - w1;
2103
-
2104
- return Color.rgb(
2105
- w1 * color1.red() + w2 * color2.red(),
2106
- w1 * color1.green() + w2 * color2.green(),
2107
- w1 * color1.blue() + w2 * color2.blue(),
2108
- color1.alpha() * p + color2.alpha() * (1 - p));
2109
- }
2110
- };
2111
-
2112
- // model conversion methods and static constructors
2113
- Object.keys(convert).forEach(function (model) {
2114
- if (skippedModels.indexOf(model) !== -1) {
2115
- return;
2116
- }
2117
-
2118
- var channels = convert[model].channels;
2119
-
2120
- // conversion methods
2121
- Color.prototype[model] = function () {
2122
- if (this.model === model) {
2123
- return new Color(this);
2124
- }
2125
-
2126
- if (arguments.length) {
2127
- return new Color(arguments, model);
2128
- }
2129
-
2130
- var newAlpha = typeof arguments[channels] === 'number' ? channels : this.valpha;
2131
- return new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);
2132
- };
2133
-
2134
- // 'static' construction methods
2135
- Color[model] = function (color) {
2136
- if (typeof color === 'number') {
2137
- color = zeroArray(_slice.call(arguments), channels);
2138
- }
2139
- return new Color(color, model);
2140
- };
2141
- });
2142
-
2143
- function roundTo(num, places) {
2144
- return Number(num.toFixed(places));
2145
- }
2146
-
2147
- function roundToPlace(places) {
2148
- return function (num) {
2149
- return roundTo(num, places);
2150
- };
2151
- }
2152
-
2153
- function getset(model, channel, modifier) {
2154
- model = Array.isArray(model) ? model : [model];
2155
-
2156
- model.forEach(function (m) {
2157
- (limiters[m] || (limiters[m] = []))[channel] = modifier;
2158
- });
2159
-
2160
- model = model[0];
2161
-
2162
- return function (val) {
2163
- var result;
2164
-
2165
- if (arguments.length) {
2166
- if (modifier) {
2167
- val = modifier(val);
2168
- }
2169
-
2170
- result = this[model]();
2171
- result.color[channel] = val;
2172
- return result;
2173
- }
2174
-
2175
- result = this[model]().color[channel];
2176
- if (modifier) {
2177
- result = modifier(result);
2178
- }
2179
-
2180
- return result;
2181
- };
2182
- }
2183
-
2184
- function maxfn(max) {
2185
- return function (v) {
2186
- return Math.max(0, Math.min(max, v));
2187
- };
2188
- }
2189
-
2190
- function assertArray(val) {
2191
- return Array.isArray(val) ? val : [val];
2192
- }
2193
-
2194
- function zeroArray(arr, length) {
2195
- for (var i = 0; i < length; i++) {
2196
- if (typeof arr[i] !== 'number') {
2197
- arr[i] = 0;
2198
- }
2199
- }
2200
-
2201
- return arr;
2202
- }
2203
-
2204
- color = Color;
2205
- return color;
2206
- }
2207
-
2208
- requireColor();
2209
-
2210
- requireColorString();
2211
-
2212
18
  const funnelDefs = [
2213
19
  { id: 1, height: 400, width: 100, x: 10, y: 10, drop: 20 },
2214
20
  { id: 2, height: 356, width: 100, x: 120, y: 32, drop: 20 },