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