PageSourceSearch

http://ccastreetsboro.com/js/tinycolor.js

js ccastreetsboro.com collected 2026-10-03 02:31:30 UTC 40,035 bytes, 1,190 lines download raw bytes

vendor: 6,616 bytes, lines 1-159
1//Source: https://github.com/bgrins/TinyColor/blob/master/npm/cjs/tinycolor.js
2
3// This file is autogenerated. It's used to publish CJS to npm.
4(function (global, factory) {
5    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
6    typeof define === 'function' && define.amd ? define(factory) :
7    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.tinycolor = factory());
8  })(this, (function () { 'use strict';
9  
10    function _typeof(obj) {
11      "@babel/helpers - typeof";
12  
13      return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
14        return typeof obj;
15      } : function (obj) {
16        return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
17      }, _typeof(obj);
18    }
19  
20    // https://github.com/bgrins/TinyColor
21    // Brian Grinstead, MIT License
22  
23    var trimLeft = /^\s+/;
24    var trimRight = /\s+$/;
25    function tinycolor(color, opts) {
26      color = color ? color : "";
27      opts = opts || {};
28  
29      // If input is already a tinycolor, return itself
30      if (color instanceof tinycolor) {
31        return color;
32      }
33      // If we are called as a function, call using new instead
34      if (!(this instanceof tinycolor)) {
35        return new tinycolor(color, opts);
36      }
37      var rgb = inputToRGB(color);
38      this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
39      this._gradientType = opts.gradientType;
40  
41      // Don't let the range of [0,255] come back in [0,1].
42      // Potentially lose a little bit of precision here, but will fix issues where
43      // .5 gets interpreted as half of the total, instead of half of 1
44      // If it was supposed to be 128, this was already taken care of by `inputToRgb`
45      if (this._r < 1) this._r = Math.round(this._r);
46      if (this._g < 1) this._g = Math.round(this._g);
47      if (this._b < 1) this._b = Math.round(this._b);
48      this._ok = rgb.ok;
49    }
50    tinycolor.prototype = {
51      isDark: function isDark() {
52        return this.getBrightness() < 128;
53      },
54      isLight: function isLight() {
55        return !this.isDark();
56      },
57      isValid: function isValid() {
58        return this._ok;
59      },
60      getOriginalInput: function getOriginalInput() {
61        return this._originalInput;
62      },
63      getFormat: function getFormat() {
64        return this._format;
65      },
66      getAlpha: function getAlpha() {
67        return this._a;
68      },
69      getBrightness: function getBrightness() {
70        //http://www.w3.org/TR/AERT#color-contrast
71        var rgb = this.toRgb();
72        return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
73      },
74      getLuminance: function getLuminance() {
75        //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
76        var rgb = this.toRgb();
77        var RsRGB, GsRGB, BsRGB, R, G, B;
78        RsRGB = rgb.r / 255;
79        GsRGB = rgb.g / 255;
80        BsRGB = rgb.b / 255;
81        if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
82        if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
83        if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
84        return 0.2126 * R + 0.7152 * G + 0.0722 * B;
85      },
86      setAlpha: function setAlpha(value) {
87        this._a = boundAlpha(value);
88        this._roundA = Math.round(100 * this._a) / 100;
89        return this;
90      },
91      toHsv: function toHsv() {
92        var hsv = rgbToHsv(this._r, this._g, this._b);
93        return {
94          h: hsv.h * 360,
95          s: hsv.s,
96          v: hsv.v,
97          a: this._a
98        };
99      },
100      toHsvString: function toHsvString() {
101        var hsv = rgbToHsv(this._r, this._g, this._b);
102        var h = Math.round(hsv.h * 360),
103          s = Math.round(hsv.s * 100),
104          v = Math.round(hsv.v * 100);
105        return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
106      },
107      toHsl: function toHsl() {
108        var hsl = rgbToHsl(this._r, this._g, this._b);
109        return {
110          h: hsl.h * 360,
111          s: hsl.s,
112          l: hsl.l,
113          a: this._a
114        };
115      },
116      toHslString: function toHslString() {
117        var hsl = rgbToHsl(this._r, this._g, this._b);
118        var h = Math.round(hsl.h * 360),
119          s = Math.round(hsl.s * 100),
120          l = Math.round(hsl.l * 100);
121        return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
122      },
123      toHex: function toHex(allow3Char) {
124        return rgbToHex(this._r, this._g, this._b, allow3Char);
125      },
126      toHexString: function toHexString(allow3Char) {
127        return "#" + this.toHex(allow3Char);
128      },
129      toHex8: function toHex8(allow4Char) {
130        return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
131      },
132      toHex8String: function toHex8String(allow4Char) {
133        return "#" + this.toHex8(allow4Char);
134      },
135      toRgb: function toRgb() {
136        return {
137          r: Math.round(this._r),
138          g: Math.round(this._g),
139          b: Math.round(this._b),
140          a: this._a
141        };
142      },
143      toRgbString: function toRgbString() {
144        return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
145      },
146      toPercentageRgb: function toPercentageRgb() {
147        return {
148          r: Math.round(bound01(this._r, 255) * 100) + "%",
149          g: Math.round(bound01(this._g, 255) * 100) + "%",
150          b: Math.round(bound01(this._b, 255) * 100) + "%",
151          a: this._a
152        };
153      },
154      toPercentageRgbString: function toPercentageRgbString() {
155        return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
156      },
157      toName: function toName() {
158        if (this._a === 0) {
159          return "transparent";
vendor: 29,415 bytes, lines 160-1054
160        }
161        if (this._a < 1) {
162          return false;
163        }
164        return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
165      },
166      toFilter: function toFilter(secondColor) {
167        var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
168        var secondHex8String = hex8String;
169        var gradientType = this._gradientType ? "GradientType = 1, " : "";
170        if (secondColor) {
171          var s = tinycolor(secondColor);
172          secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
173        }
174        return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
175      },
176      toString: function toString(format) {
177        var formatSet = !!format;
178        format = format || this._format;
179        var formattedString = false;
180        var hasAlpha = this._a < 1 && this._a >= 0;
181        var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
182        if (needsAlphaFormat) {
183          // Special case for "transparent", all other non-alpha formats
184          // will return rgba when there is transparency.
185          if (format === "name" && this._a === 0) {
186            return this.toName();
187          }
188          return this.toRgbString();
189        }
190        if (format === "rgb") {
191          formattedString = this.toRgbString();
192        }
193        if (format === "prgb") {
194          formattedString = this.toPercentageRgbString();
195        }
196        if (format === "hex" || format === "hex6") {
197          formattedString = this.toHexString();
198        }
199        if (format === "hex3") {
200          formattedString = this.toHexString(true);
201        }
202        if (format === "hex4") {
203          formattedString = this.toHex8String(true);
204        }
205        if (format === "hex8") {
206          formattedString = this.toHex8String();
207        }
208        if (format === "name") {
209          formattedString = this.toName();
210        }
211        if (format === "hsl") {
212          formattedString = this.toHslString();
213        }
214        if (format === "hsv") {
215          formattedString = this.toHsvString();
216        }
217        return formattedString || this.toHexString();
218      },
219      clone: function clone() {
220        return tinycolor(this.toString());
221      },
222      _applyModification: function _applyModification(fn, args) {
223        var color = fn.apply(null, [this].concat([].slice.call(args)));
224        this._r = color._r;
225        this._g = color._g;
226        this._b = color._b;
227        this.setAlpha(color._a);
228        return this;
229      },
230      lighten: function lighten() {
231        return this._applyModification(_lighten, arguments);
232      },
233      brighten: function brighten() {
234        return this._applyModification(_brighten, arguments);
235      },
236      darken: function darken() {
237        return this._applyModification(_darken, arguments);
238      },
239      desaturate: function desaturate() {
240        return this._applyModification(_desaturate, arguments);
241      },
242      saturate: function saturate() {
243        return this._applyModification(_saturate, arguments);
244      },
245      greyscale: function greyscale() {
246        return this._applyModification(_greyscale, arguments);
247      },
248      spin: function spin() {
249        return this._applyModification(_spin, arguments);
250      },
251      _applyCombination: function _applyCombination(fn, args) {
252        return fn.apply(null, [this].concat([].slice.call(args)));
253      },
254      analogous: function analogous() {
255        return this._applyCombination(_analogous, arguments);
256      },
257      complement: function complement() {
258        return this._applyCombination(_complement, arguments);
259      },
260      monochromatic: function monochromatic() {
261        return this._applyCombination(_monochromatic, arguments);
262      },
263      splitcomplement: function splitcomplement() {
264        return this._applyCombination(_splitcomplement, arguments);
265      },
266      // Disabled until https://github.com/bgrins/TinyColor/issues/254
267      // polyad: function (number) {
268      //   return this._applyCombination(polyad, [number]);
269      // },
270      triad: function triad() {
271        return this._applyCombination(polyad, [3]);
272      },
273      tetrad: function tetrad() {
274        return this._applyCombination(polyad, [4]);
275      }
276    };
277  
278    // If input is an object, force 1 into "1.0" to handle ratios properly
279    // String input requires "1.0" as input, so 1 will be treated as 1
280    tinycolor.fromRatio = function (color, opts) {
281      if (_typeof(color) == "object") {
282        var newColor = {};
283        for (var i in color) {
284          if (color.hasOwnProperty(i)) {
285            if (i === "a") {
286              newColor[i] = color[i];
287            } else {
288              newColor[i] = convertToPercentage(color[i]);
289            }
290          }
291        }
292        color = newColor;
293      }
294      return tinycolor(color, opts);
295    };
296  
297    // Given a string or object, convert that input to RGB
298    // Possible string inputs:
299    //
300    //     "red"
301    //     "#f00" or "f00"
302    //     "#ff0000" or "ff0000"
303    //     "#ff000000" or "ff000000"
304    //     "rgb 255 0 0" or "rgb (255, 0, 0)"
305    //     "rgb 1.0 0 0" or "rgb (1, 0, 0)"
306    //     "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
307    //     "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
308    //     "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
309    //     "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
310    //     "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
311    //
312    function inputToRGB(color) {
313      var rgb = {
314        r: 0,
315        g: 0,
316        b: 0
317      };
318      var a = 1;
319      var s = null;
320      var v = null;
321      var l = null;
322      var ok = false;
323      var format = false;
324      if (typeof color == "string") {
325        color = stringInputToObject(color);
326      }
327      if (_typeof(color) == "object") {
328        if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
329          rgb = rgbToRgb(color.r, color.g, color.b);
330          ok = true;
331          format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
332        } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
333          s = convertToPercentage(color.s);
334          v = convertToPercentage(color.v);
335          rgb = hsvToRgb(color.h, s, v);
336          ok = true;
337          format = "hsv";
338        } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
339          s = convertToPercentage(color.s);
340          l = convertToPercentage(color.l);
341          rgb = hslToRgb(color.h, s, l);
342          ok = true;
343          format = "hsl";
344        }
345        if (color.hasOwnProperty("a")) {
346          a = color.a;
347        }
348      }
349      a = boundAlpha(a);
350      return {
351        ok: ok,
352        format: color.format || format,
353        r: Math.min(255, Math.max(rgb.r, 0)),
354        g: Math.min(255, Math.max(rgb.g, 0)),
355        b: Math.min(255, Math.max(rgb.b, 0)),
356        a: a
357      };
358    }
359  
360    // Conversion Functions
361    // --------------------
362  
363    // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
364    // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
365  
366    // `rgbToRgb`
367    // Handle bounds / percentage checking to conform to CSS color spec
368    // <http://www.w3.org/TR/css3-color/>
369    // *Assumes:* r, g, b in [0, 255] or [0, 1]
370    // *Returns:* { r, g, b } in [0, 255]
371    function rgbToRgb(r, g, b) {
372      return {
373        r: bound01(r, 255) * 255,
374        g: bound01(g, 255) * 255,
375        b: bound01(b, 255) * 255
376      };
377    }
378  
379    // `rgbToHsl`
380    // Converts an RGB color value to HSL.
381    // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
382    // *Returns:* { h, s, l } in [0,1]
383    function rgbToHsl(r, g, b) {
384      r = bound01(r, 255);
385      g = bound01(g, 255);
386      b = bound01(b, 255);
387      var max = Math.max(r, g, b),
388        min = Math.min(r, g, b);
389      var h,
390        s,
391        l = (max + min) / 2;
392      if (max == min) {
393        h = s = 0; // achromatic
394      } else {
395        var d = max - min;
396        s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
397        switch (max) {
398          case r:
399            h = (g - b) / d + (g < b ? 6 : 0);
400            break;
401          case g:
402            h = (b - r) / d + 2;
403            break;
404          case b:
405            h = (r - g) / d + 4;
406            break;
407        }
408        h /= 6;
409      }
410      return {
411        h: h,
412        s: s,
413        l: l
414      };
415    }
416  
417    // `hslToRgb`
418    // Converts an HSL color value to RGB.
419    // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
420    // *Returns:* { r, g, b } in the set [0, 255]
421    function hslToRgb(h, s, l) {
422      var r, g, b;
423      h = bound01(h, 360);
424      s = bound01(s, 100);
425      l = bound01(l, 100);
426      function hue2rgb(p, q, t) {
427        if (t < 0) t += 1;
428        if (t > 1) t -= 1;
429        if (t < 1 / 6) return p + (q - p) * 6 * t;
430        if (t < 1 / 2) return q;
431        if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
432        return p;
433      }
434      if (s === 0) {
435        r = g = b = l; // achromatic
436      } else {
437        var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
438        var p = 2 * l - q;
439        r = hue2rgb(p, q, h + 1 / 3);
440        g = hue2rgb(p, q, h);
441        b = hue2rgb(p, q, h - 1 / 3);
442      }
443      return {
444        r: r * 255,
445        g: g * 255,
446        b: b * 255
447      };
448    }
449  
450    // `rgbToHsv`
451    // Converts an RGB color value to HSV
452    // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
453    // *Returns:* { h, s, v } in [0,1]
454    function rgbToHsv(r, g, b) {
455      r = bound01(r, 255);
456      g = bound01(g, 255);
457      b = bound01(b, 255);
458      var max = Math.max(r, g, b),
459        min = Math.min(r, g, b);
460      var h,
461        s,
462        v = max;
463      var d = max - min;
464      s = max === 0 ? 0 : d / max;
465      if (max == min) {
466        h = 0; // achromatic
467      } else {
468        switch (max) {
469          case r:
470            h = (g - b) / d + (g < b ? 6 : 0);
471            break;
472          case g:
473            h = (b - r) / d + 2;
474            break;
475          case b:
476            h = (r - g) / d + 4;
477            break;
478        }
479        h /= 6;
480      }
481      return {
482        h: h,
483        s: s,
484        v: v
485      };
486    }
487  
488    // `hsvToRgb`
489    // Converts an HSV color value to RGB.
490    // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
491    // *Returns:* { r, g, b } in the set [0, 255]
492    function hsvToRgb(h, s, v) {
493      h = bound01(h, 360) * 6;
494      s = bound01(s, 100);
495      v = bound01(v, 100);
496      var i = Math.floor(h),
497        f = h - i,
498        p = v * (1 - s),
499        q = v * (1 - f * s),
500        t = v * (1 - (1 - f) * s),
501        mod = i % 6,
502        r = [v, q, p, p, t, v][mod],
503        g = [t, v, v, q, p, p][mod],
504        b = [p, p, t, v, v, q][mod];
505      return {
506        r: r * 255,
507        g: g * 255,
508        b: b * 255
509      };
510    }
511  
512    // `rgbToHex`
513    // Converts an RGB color to hex
514    // Assumes r, g, and b are contained in the set [0, 255]
515    // Returns a 3 or 6 character hex
516    function rgbToHex(r, g, b, allow3Char) {
517      var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
518  
519      // Return a 3 character hex if possible
520      if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
521        return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
522      }
523      return hex.join("");
524    }
525  
526    // `rgbaToHex`
527    // Converts an RGBA color plus alpha transparency to hex
528    // Assumes r, g, b are contained in the set [0, 255] and
529    // a in [0, 1]. Returns a 4 or 8 character rgba hex
530    function rgbaToHex(r, g, b, a, allow4Char) {
531      var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
532  
533      // Return a 4 character hex if possible
534      if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
535        return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
536      }
537      return hex.join("");
538    }
539  
540    // `rgbaToArgbHex`
541    // Converts an RGBA color to an ARGB Hex8 string
542    // Rarely used, but required for "toFilter()"
543    function rgbaToArgbHex(r, g, b, a) {
544      var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
545      return hex.join("");
546    }
547  
548    // `equals`
549    // Can be called with any tinycolor input
550    tinycolor.equals = function (color1, color2) {
551      if (!color1 || !color2) return false;
552      return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
553    };
554    tinycolor.random = function () {
555      return tinycolor.fromRatio({
556        r: Math.random(),
557        g: Math.random(),
558        b: Math.random()
559      });
560    };
561  
562    // Modification Functions
563    // ----------------------
564    // Thanks to less.js for some of the basics here
565    // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
566  
567    function _desaturate(color, amount) {
568      amount = amount === 0 ? 0 : amount || 10;
569      var hsl = tinycolor(color).toHsl();
570      hsl.s -= amount / 100;
571      hsl.s = clamp01(hsl.s);
572      return tinycolor(hsl);
573    }
574    function _saturate(color, amount) {
575      amount = amount === 0 ? 0 : amount || 10;
576      var hsl = tinycolor(color).toHsl();
577      hsl.s += amount / 100;
578      hsl.s = clamp01(hsl.s);
579      return tinycolor(hsl);
580    }
581    function _greyscale(color) {
582      return tinycolor(color).desaturate(100);
583    }
584    function _lighten(color, amount) {
585      amount = amount === 0 ? 0 : amount || 10;
586      var hsl = tinycolor(color).toHsl();
587      hsl.l += amount / 100;
588      hsl.l = clamp01(hsl.l);
589      return tinycolor(hsl);
590    }
591    function _brighten(color, amount) {
592      amount = amount === 0 ? 0 : amount || 10;
593      var rgb = tinycolor(color).toRgb();
594      rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
595      rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
596      rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
597      return tinycolor(rgb);
598    }
599    function _darken(color, amount) {
600      amount = amount === 0 ? 0 : amount || 10;
601      var hsl = tinycolor(color).toHsl();
602      hsl.l -= amount / 100;
603      hsl.l = clamp01(hsl.l);
604      return tinycolor(hsl);
605    }
606  
607    // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
608    // Values outside of this range will be wrapped into this range.
609    function _spin(color, amount) {
610      var hsl = tinycolor(color).toHsl();
611      var hue = (hsl.h + amount) % 360;
612      hsl.h = hue < 0 ? 360 + hue : hue;
613      return tinycolor(hsl);
614    }
615  
616    // Combination Functions
617    // ---------------------
618    // Thanks to jQuery xColor for some of the ideas behind these
619    // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
620  
621    function _complement(color) {
622      var hsl = tinycolor(color).toHsl();
623      hsl.h = (hsl.h + 180) % 360;
624      return tinycolor(hsl);
625    }
626    function polyad(color, number) {
627      if (isNaN(number) || number <= 0) {
628        throw new Error("Argument to polyad must be a positive number");
629      }
630      var hsl = tinycolor(color).toHsl();
631      var result = [tinycolor(color)];
632      var step = 360 / number;
633      for (var i = 1; i < number; i++) {
634        result.push(tinycolor({
635          h: (hsl.h + i * step) % 360,
636          s: hsl.s,
637          l: hsl.l
638        }));
639      }
640      return result;
641    }
642    function _splitcomplement(color) {
643      var hsl = tinycolor(color).toHsl();
644      var h = hsl.h;
645      return [tinycolor(color), tinycolor({
646        h: (h + 72) % 360,
647        s: hsl.s,
648        l: hsl.l
649      }), tinycolor({
650        h: (h + 216) % 360,
651        s: hsl.s,
652        l: hsl.l
653      })];
654    }
655    function _analogous(color, results, slices) {
656      results = results || 6;
657      slices = slices || 30;
658      var hsl = tinycolor(color).toHsl();
659      var part = 360 / slices;
660      var ret = [tinycolor(color)];
661      for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
662        hsl.h = (hsl.h + part) % 360;
663        ret.push(tinycolor(hsl));
664      }
665      return ret;
666    }
667    function _monochromatic(color, results) {
668      results = results || 6;
669      var hsv = tinycolor(color).toHsv();
670      var h = hsv.h,
671        s = hsv.s,
672        v = hsv.v;
673      var ret = [];
674      var modification = 1 / results;
675      while (results--) {
676        ret.push(tinycolor({
677          h: h,
678          s: s,
679          v: v
680        }));
681        v = (v + modification) % 1;
682      }
683      return ret;
684    }
685  
686    // Utility Functions
687    // ---------------------
688  
689    tinycolor.mix = function (color1, color2, amount) {
690      amount = amount === 0 ? 0 : amount || 50;
691      var rgb1 = tinycolor(color1).toRgb();
692      var rgb2 = tinycolor(color2).toRgb();
693      var p = amount / 100;
694      var rgba = {
695        r: (rgb2.r - rgb1.r) * p + rgb1.r,
696        g: (rgb2.g - rgb1.g) * p + rgb1.g,
697        b: (rgb2.b - rgb1.b) * p + rgb1.b,
698        a: (rgb2.a - rgb1.a) * p + rgb1.a
699      };
700      return tinycolor(rgba);
701    };
702  
703    // Readability Functions
704    // ---------------------
705    // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
706  
707    // `contrast`
708    // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
709    tinycolor.readability = function (color1, color2) {
710      var c1 = tinycolor(color1);
711      var c2 = tinycolor(color2);
712      return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
713    };
714  
715    // `isReadable`
716    // Ensure that foreground and background color combinations meet WCAG2 guidelines.
717    // The third argument is an optional Object.
718    //      the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
719    //      the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
720    // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
721  
722    // *Example*
723    //    tinycolor.isReadable("#000", "#111") => false
724    //    tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
725    tinycolor.isReadable = function (color1, color2, wcag2) {
726      var readability = tinycolor.readability(color1, color2);
727      var wcag2Parms, out;
728      out = false;
729      wcag2Parms = validateWCAG2Parms(wcag2);
730      switch (wcag2Parms.level + wcag2Parms.size) {
731        case "AAsmall":
732        case "AAAlarge":
733          out = readability >= 4.5;
734          break;
735        case "AAlarge":
736          out = readability >= 3;
737          break;
738        case "AAAsmall":
739          out = readability >= 7;
740          break;
741      }
742      return out;
743    };
744  
745    // `mostReadable`
746    // Given a base color and a list of possible foreground or background
747    // colors for that base, returns the most readable color.
748    // Optionally returns Black or White if the most readable color is unreadable.
749    // *Example*
750    //    tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
751    //    tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString();  // "#ffffff"
752    //    tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
753    //    tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
754    tinycolor.mostReadable = function (baseColor, colorList, args) {
755      var bestColor = null;
756      var bestScore = 0;
757      var readability;
758      var includeFallbackColors, level, size;
759      args = args || {};
760      includeFallbackColors = args.includeFallbackColors;
761      level = args.level;
762      size = args.size;
763      for (var i = 0; i < colorList.length; i++) {
764        readability = tinycolor.readability(baseColor, colorList[i]);
765        if (readability > bestScore) {
766          bestScore = readability;
767          bestColor = tinycolor(colorList[i]);
768        }
769      }
770      if (tinycolor.isReadable(baseColor, bestColor, {
771        level: level,
772        size: size
773      }) || !includeFallbackColors) {
774        return bestColor;
775      } else {
776        args.includeFallbackColors = false;
777        return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
778      }
779    };
780  
781    // Big List of Colors
782    // ------------------
783    // <https://www.w3.org/TR/css-color-4/#named-colors>
784    var names = tinycolor.names = {
785      aliceblue: "f0f8ff",
786      antiquewhite: "faebd7",
787      aqua: "0ff",
788      aquamarine: "7fffd4",
789      azure: "f0ffff",
790      beige: "f5f5dc",
791      bisque: "ffe4c4",
792      black: "000",
793      blanchedalmond: "ffebcd",
794      blue: "00f",
795      blueviolet: "8a2be2",
796      brown: "a52a2a",
797      burlywood: "deb887",
798      burntsienna: "ea7e5d",
799      cadetblue: "5f9ea0",
800      chartreuse: "7fff00",
801      chocolate: "d2691e",
802      coral: "ff7f50",
803      cornflowerblue: "6495ed",
804      cornsilk: "fff8dc",
805      crimson: "dc143c",
806      cyan: "0ff",
807      darkblue: "00008b",
808      darkcyan: "008b8b",
809      darkgoldenrod: "b8860b",
810      darkgray: "a9a9a9",
811      darkgreen: "006400",
812      darkgrey: "a9a9a9",
813      darkkhaki: "bdb76b",
814      darkmagenta: "8b008b",
815      darkolivegreen: "556b2f",
816      darkorange: "ff8c00",
817      darkorchid: "9932cc",
818      darkred: "8b0000",
819      darksalmon: "e9967a",
820      darkseagreen: "8fbc8f",
821      darkslateblue: "483d8b",
822      darkslategray: "2f4f4f",
823      darkslategrey: "2f4f4f",
824      darkturquoise: "00ced1",
825      darkviolet: "9400d3",
826      deeppink: "ff1493",
827      deepskyblue: "00bfff",
828      dimgray: "696969",
829      dimgrey: "696969",
830      dodgerblue: "1e90ff",
831      firebrick: "b22222",
832      floralwhite: "fffaf0",
833      forestgreen: "228b22",
834      fuchsia: "f0f",
835      gainsboro: "dcdcdc",
836      ghostwhite: "f8f8ff",
837      gold: "ffd700",
838      goldenrod: "daa520",
839      gray: "808080",
840      green: "008000",
841      greenyellow: "adff2f",
842      grey: "808080",
843      honeydew: "f0fff0",
844      hotpink: "ff69b4",
845      indianred: "cd5c5c",
846      indigo: "4b0082",
847      ivory: "fffff0",
848      khaki: "f0e68c",
849      lavender: "e6e6fa",
850      lavenderblush: "fff0f5",
851      lawngreen: "7cfc00",
852      lemonchiffon: "fffacd",
853      lightblue: "add8e6",
854      lightcoral: "f08080",
855      lightcyan: "e0ffff",
856      lightgoldenrodyellow: "fafad2",
857      lightgray: "d3d3d3",
858      lightgreen: "90ee90",
859      lightgrey: "d3d3d3",
860      lightpink: "ffb6c1",
861      lightsalmon: "ffa07a",
862      lightseagreen: "20b2aa",
863      lightskyblue: "87cefa",
864      lightslategray: "789",
865      lightslategrey: "789",
866      lightsteelblue: "b0c4de",
867      lightyellow: "ffffe0",
868      lime: "0f0",
869      limegreen: "32cd32",
870      linen: "faf0e6",
871      magenta: "f0f",
872      maroon: "800000",
873      mediumaquamarine: "66cdaa",
874      mediumblue: "0000cd",
875      mediumorchid: "ba55d3",
876      mediumpurple: "9370db",
877      mediumseagreen: "3cb371",
878      mediumslateblue: "7b68ee",
879      mediumspringgreen: "00fa9a",
880      mediumturquoise: "48d1cc",
881      mediumvioletred: "c71585",
882      midnightblue: "191970",
883      mintcream: "f5fffa",
884      mistyrose: "ffe4e1",
885      moccasin: "ffe4b5",
886      navajowhite: "ffdead",
887      navy: "000080",
888      oldlace: "fdf5e6",
889      olive: "808000",
890      olivedrab: "6b8e23",
891      orange: "ffa500",
892      orangered: "ff4500",
893      orchid: "da70d6",
894      palegoldenrod: "eee8aa",
895      palegreen: "98fb98",
896      paleturquoise: "afeeee",
897      palevioletred: "db7093",
898      papayawhip: "ffefd5",
899      peachpuff: "ffdab9",
900      peru: "cd853f",
901      pink: "ffc0cb",
902      plum: "dda0dd",
903      powderblue: "b0e0e6",
904      purple: "800080",
905      rebeccapurple: "663399",
906      red: "f00",
907      rosybrown: "bc8f8f",
908      royalblue: "4169e1",
909      saddlebrown: "8b4513",
910      salmon: "fa8072",
911      sandybrown: "f4a460",
912      seagreen: "2e8b57",
913      seashell: "fff5ee",
914      sienna: "a0522d",
915      silver: "c0c0c0",
916      skyblue: "87ceeb",
917      slateblue: "6a5acd",
918      slategray: "708090",
919      slategrey: "708090",
920      snow: "fffafa",
921      springgreen: "00ff7f",
922      steelblue: "4682b4",
923      tan: "d2b48c",
924      teal: "008080",
925      thistle: "d8bfd8",
926      tomato: "ff6347",
927      turquoise: "40e0d0",
928      violet: "ee82ee",
929      wheat: "f5deb3",
930      white: "fff",
931      whitesmoke: "f5f5f5",
932      yellow: "ff0",
933      yellowgreen: "9acd32"
934    };
935  
936    // Make it easy to access colors via `hexNames[hex]`
937    var hexNames = tinycolor.hexNames = flip(names);
938  
939    // Utilities
940    // ---------
941  
942    // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
943    function flip(o) {
944      var flipped = {};
945      for (var i in o) {
946        if (o.hasOwnProperty(i)) {
947          flipped[o[i]] = i;
948        }
949      }
950      return flipped;
951    }
952  
953    // Return a valid alpha value [0,1] with all invalid values being set to 1
954    function boundAlpha(a) {
955      a = parseFloat(a);
956      if (isNaN(a) || a < 0 || a > 1) {
957        a = 1;
958      }
959      return a;
960    }
961  
962    // Take input from [0, n] and return it as [0, 1]
963    function bound01(n, max) {
964      if (isOnePointZero(n)) n = "100%";
965      var processPercent = isPercentage(n);
966      n = Math.min(max, Math.max(0, parseFloat(n)));
967  
968      // Automatically convert percentage into number
969      if (processPercent) {
970        n = parseInt(n * max, 10) / 100;
971      }
972  
973      // Handle floating point rounding errors
974      if (Math.abs(n - max) < 0.000001) {
975        return 1;
976      }
977  
978      // Convert into [0, 1] range if it isn't already
979      return n % max / parseFloat(max);
980    }
981  
982    // Force a number between 0 and 1
983    function clamp01(val) {
984      return Math.min(1, Math.max(0, val));
985    }
986  
987    // Parse a base-16 hex value into a base-10 integer
988    function parseIntFromHex(val) {
989      return parseInt(val, 16);
990    }
991  
992    // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
993    // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
994    function isOnePointZero(n) {
995      return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
996    }
997  
998    // Check to see if string passed in is a percentage
999    function isPercentage(n) {
1000      return typeof n === "string" && n.indexOf("%") != -1;
1001    }
1002  
1003    // Force a hex value to have 2 characters
1004    function pad2(c) {
1005      return c.length == 1 ? "0" + c : "" + c;
1006    }
1007  
1008    // Replace a decimal with it's percentage value
1009    function convertToPercentage(n) {
1010      if (n <= 1) {
1011        n = n * 100 + "%";
1012      }
1013      return n;
1014    }
1015  
1016    // Converts a decimal to a hex value
1017    function convertDecimalToHex(d) {
1018      return Math.round(parseFloat(d) * 255).toString(16);
1019    }
1020    // Converts a hex value to a decimal
1021    function convertHexToDecimal(h) {
1022      return parseIntFromHex(h) / 255;
1023    }
1024    var matchers = function () {
1025      // <http://www.w3.org/TR/css3-values/#integers>
1026      var CSS_INTEGER = "[-\\+]?\\d+%?";
1027  
1028      // <http://www.w3.org/TR/css3-values/#number-value>
1029      var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1030  
1031      // Allow positive/negative integer/number.  Don't capture the either/or, just the entire outcome.
1032      var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1033  
1034      // Actual matching.
1035      // Parentheses and commas are optional, but not required.
1036      // Whitespace can take the place of commas or opening paren
1037      var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1038      var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1039      return {
1040        CSS_UNIT: new RegExp(CSS_UNIT),
1041        rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
1042        rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
1043        hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
1044        hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
1045        hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
1046        hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
1047        hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1048        hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1049        hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1050        hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1051      };
1052    }();
1053  
1054    // `isValidCSSUnit`
vendor: 4,004 bytes, lines 1055-1190
1055    // Take in a single string / number and check to see if it looks like a CSS unit
1056    // (see `matchers` above for definition).
1057    function isValidCSSUnit(color) {
1058      return !!matchers.CSS_UNIT.exec(color);
1059    }
1060  
1061    // `stringInputToObject`
1062    // Permissive string parsing.  Take in a number of formats, and output an object
1063    // based on detected format.  Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
1064    function stringInputToObject(color) {
1065      color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
1066      var named = false;
1067      if (names[color]) {
1068        color = names[color];
1069        named = true;
1070      } else if (color == "transparent") {
1071        return {
1072          r: 0,
1073          g: 0,
1074          b: 0,
1075          a: 0,
1076          format: "name"
1077        };
1078      }
1079  
1080      // Try to match string input using regular expressions.
1081      // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
1082      // Just return an object and let the conversion functions handle that.
1083      // This way the result will be the same whether the tinycolor is initialized with string or object.
1084      var match;
1085      if (match = matchers.rgb.exec(color)) {
1086        return {
1087          r: match[1],
1088          g: match[2],
1089          b: match[3]
1090        };
1091      }
1092      if (match = matchers.rgba.exec(color)) {
1093        return {
1094          r: match[1],
1095          g: match[2],
1096          b: match[3],
1097          a: match[4]
1098        };
1099      }
1100      if (match = matchers.hsl.exec(color)) {
1101        return {
1102          h: match[1],
1103          s: match[2],
1104          l: match[3]
1105        };
1106      }
1107      if (match = matchers.hsla.exec(color)) {
1108        return {
1109          h: match[1],
1110          s: match[2],
1111          l: match[3],
1112          a: match[4]
1113        };
1114      }
1115      if (match = matchers.hsv.exec(color)) {
1116        return {
1117          h: match[1],
1118          s: match[2],
1119          v: match[3]
1120        };
1121      }
1122      if (match = matchers.hsva.exec(color)) {
1123        return {
1124          h: match[1],
1125          s: match[2],
1126          v: match[3],
1127          a: match[4]
1128        };
1129      }
1130      if (match = matchers.hex8.exec(color)) {
1131        return {
1132          r: parseIntFromHex(match[1]),
1133          g: parseIntFromHex(match[2]),
1134          b: parseIntFromHex(match[3]),
1135          a: convertHexToDecimal(match[4]),
1136          format: named ? "name" : "hex8"
1137        };
1138      }
1139      if (match = matchers.hex6.exec(color)) {
1140        return {
1141          r: parseIntFromHex(match[1]),
1142          g: parseIntFromHex(match[2]),
1143          b: parseIntFromHex(match[3]),
1144          format: named ? "name" : "hex"
1145        };
1146      }
1147      if (match = matchers.hex4.exec(color)) {
1148        return {
1149          r: parseIntFromHex(match[1] + "" + match[1]),
1150          g: parseIntFromHex(match[2] + "" + match[2]),
1151          b: parseIntFromHex(match[3] + "" + match[3]),
1152          a: convertHexToDecimal(match[4] + "" + match[4]),
1153          format: named ? "name" : "hex8"
1154        };
1155      }
1156      if (match = matchers.hex3.exec(color)) {
1157        return {
1158          r: parseIntFromHex(match[1] + "" + match[1]),
1159          g: parseIntFromHex(match[2] + "" + match[2]),
1160          b: parseIntFromHex(match[3] + "" + match[3]),
1161          format: named ? "name" : "hex"
1162        };
1163      }
1164      return false;
1165    }
1166    function validateWCAG2Parms(parms) {
1167      // return valid WCAG2 parms for isReadable.
1168      // If input parms are invalid, return {"level":"AA", "size":"small"}
1169      var level, size;
1170      parms = parms || {
1171        level: "AA",
1172        size: "small"
1173      };
1174      level = (parms.level || "AA").toUpperCase();
1175      size = (parms.size || "small").toLowerCase();
1176      if (level !== "AA" && level !== "AAA") {
1177        level = "AA";
1178      }
1179      if (size !== "small" && size !== "large") {
1180        size = "small";
1181      }
1182      return {
1183        level: level,
1184        size: size
1185      };
1186    }
1187  
1188    return tinycolor;
1189  
1190  }));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.