From 6fb43d3021c7c3ae3bbefdeba55ece88941c0eae Mon Sep 17 00:00:00 2001 From: David Aerne Date: Sun, 13 Oct 2024 13:56:57 +0200 Subject: [PATCH] add basic tests --- dist/index.iife.js | 4208 +---------------------------- package-lock.json | 2 +- package.json | 2 +- tests/colorDescriptionLib.test.js | 111 + 4 files changed, 114 insertions(+), 4209 deletions(-) create mode 100644 tests/colorDescriptionLib.test.js diff --git a/dist/index.iife.js b/dist/index.iife.js index c1acc6c..a21f9d5 100644 --- a/dist/index.iife.js +++ b/dist/index.iife.js @@ -1,4210 +1,4 @@ -var ColorDescription = (() => { - var __create = Object.create; - var __defProp = Object.defineProperty; - var __getOwnPropDesc = Object.getOwnPropertyDescriptor; - var __getOwnPropNames = Object.getOwnPropertyNames; - var __getProtoOf = Object.getPrototypeOf; - var __hasOwnProp = Object.prototype.hasOwnProperty; - var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); - var __require = typeof require !== "undefined" ? require : (x) => { - throw new Error('Dynamic require of "' + x + '" is not supported'); - }; - var __commonJS = (cb, mod) => function __require2() { - return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; - }; - var __export = (target, all) => { - __markAsModule(target); - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); - }; - var __reExport = (target, module, desc) => { - if (module && typeof module === "object" || typeof module === "function") { - for (let key of __getOwnPropNames(module)) - if (!__hasOwnProp.call(target, key) && key !== "default") - __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable }); - } - return target; - }; - var __toModule = (module) => { - return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module); - }; - var __accessCheck = (obj, member, msg) => { - if (!member.has(obj)) - throw TypeError("Cannot " + msg); - }; - var __privateAdd = (obj, member, value) => { - if (member.has(obj)) - throw TypeError("Cannot add the same private member more than once"); - member instanceof WeakSet ? member.add(obj) : member.set(obj, value); - }; - var __privateMethod = (obj, member, method) => { - __accessCheck(obj, member, "access private method"); - return method; - }; - - // node_modules/chroma-js/chroma.js - var require_chroma = __commonJS({ - "node_modules/chroma-js/chroma.js"(exports, module) { - (function(global, factory) { - typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.chroma = factory(); - })(exports, function() { - "use strict"; - var limit = function(x, min2, max2) { - if (min2 === void 0) - min2 = 0; - if (max2 === void 0) - max2 = 1; - return x < min2 ? min2 : x > max2 ? max2 : x; - }; - var clip_rgb = function(rgb) { - rgb._clipped = false; - rgb._unclipped = rgb.slice(0); - for (var i2 = 0; i2 <= 3; i2++) { - if (i2 < 3) { - if (rgb[i2] < 0 || rgb[i2] > 255) { - rgb._clipped = true; - } - rgb[i2] = limit(rgb[i2], 0, 255); - } else if (i2 === 3) { - rgb[i2] = limit(rgb[i2], 0, 1); - } - } - return rgb; - }; - var classToType = {}; - for (var i = 0, list = ["Boolean", "Number", "String", "Function", "Array", "Date", "RegExp", "Undefined", "Null"]; i < list.length; i += 1) { - var name = list[i]; - classToType["[object " + name + "]"] = name.toLowerCase(); - } - var type = function(obj) { - return classToType[Object.prototype.toString.call(obj)] || "object"; - }; - var unpack = function(args, keyOrder) { - if (keyOrder === void 0) - keyOrder = null; - if (args.length >= 3) { - return Array.prototype.slice.call(args); - } - if (type(args[0]) == "object" && keyOrder) { - return keyOrder.split("").filter(function(k) { - return args[0][k] !== void 0; - }).map(function(k) { - return args[0][k]; - }); - } - return args[0]; - }; - var last = function(args) { - if (args.length < 2) { - return null; - } - var l = args.length - 1; - if (type(args[l]) == "string") { - return args[l].toLowerCase(); - } - return null; - }; - var PI = Math.PI; - var utils = { - clip_rgb, - limit, - type, - unpack, - last, - PI, - TWOPI: PI * 2, - PITHIRD: PI / 3, - DEG2RAD: PI / 180, - RAD2DEG: 180 / PI - }; - var input = { - format: {}, - autodetect: [] - }; - var last$1 = utils.last; - var clip_rgb$1 = utils.clip_rgb; - var type$1 = utils.type; - var Color = function Color2() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var me = this; - if (type$1(args[0]) === "object" && args[0].constructor && args[0].constructor === this.constructor) { - return args[0]; - } - var mode = last$1(args); - var autodetect = false; - if (!mode) { - autodetect = true; - if (!input.sorted) { - input.autodetect = input.autodetect.sort(function(a, b) { - return b.p - a.p; - }); - input.sorted = true; - } - for (var i2 = 0, list2 = input.autodetect; i2 < list2.length; i2 += 1) { - var chk = list2[i2]; - mode = chk.test.apply(chk, args); - if (mode) { - break; - } - } - } - if (input.format[mode]) { - var rgb = input.format[mode].apply(null, autodetect ? args : args.slice(0, -1)); - me._rgb = clip_rgb$1(rgb); - } else { - throw new Error("unknown format: " + args); - } - if (me._rgb.length === 3) { - me._rgb.push(1); - } - }; - Color.prototype.toString = function toString() { - if (type$1(this.hex) == "function") { - return this.hex(); - } - return "[" + this._rgb.join(",") + "]"; - }; - var Color_1 = Color; - var chroma2 = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(chroma2.Color, [null].concat(args)))(); - }; - chroma2.Color = Color_1; - chroma2.version = "2.1.2"; - var chroma_1 = chroma2; - var unpack$1 = utils.unpack; - var max = Math.max; - var rgb2cmyk = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$1(args, "rgb"); - var r = ref[0]; - var g = ref[1]; - var b = ref[2]; - r = r / 255; - g = g / 255; - b = b / 255; - var k = 1 - max(r, max(g, b)); - var f = k < 1 ? 1 / (1 - k) : 0; - var c = (1 - r - k) * f; - var m = (1 - g - k) * f; - var y = (1 - b - k) * f; - return [c, m, y, k]; - }; - var rgb2cmyk_1 = rgb2cmyk; - var unpack$2 = utils.unpack; - var cmyk2rgb = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$2(args, "cmyk"); - var c = args[0]; - var m = args[1]; - var y = args[2]; - var k = args[3]; - var alpha = args.length > 4 ? args[4] : 1; - if (k === 1) { - return [0, 0, 0, alpha]; - } - return [ - c >= 1 ? 0 : 255 * (1 - c) * (1 - k), - m >= 1 ? 0 : 255 * (1 - m) * (1 - k), - y >= 1 ? 0 : 255 * (1 - y) * (1 - k), - alpha - ]; - }; - var cmyk2rgb_1 = cmyk2rgb; - var unpack$3 = utils.unpack; - var type$2 = utils.type; - Color_1.prototype.cmyk = function() { - return rgb2cmyk_1(this._rgb); - }; - chroma_1.cmyk = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["cmyk"])))(); - }; - input.format.cmyk = cmyk2rgb_1; - input.autodetect.push({ - p: 2, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$3(args, "cmyk"); - if (type$2(args) === "array" && args.length === 4) { - return "cmyk"; - } - } - }); - var unpack$4 = utils.unpack; - var last$2 = utils.last; - var rnd = function(a) { - return Math.round(a * 100) / 100; - }; - var hsl2css = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var hsla = unpack$4(args, "hsla"); - var mode = last$2(args) || "lsa"; - hsla[0] = rnd(hsla[0] || 0); - hsla[1] = rnd(hsla[1] * 100) + "%"; - hsla[2] = rnd(hsla[2] * 100) + "%"; - if (mode === "hsla" || hsla.length > 3 && hsla[3] < 1) { - hsla[3] = hsla.length > 3 ? hsla[3] : 1; - mode = "hsla"; - } else { - hsla.length = 3; - } - return mode + "(" + hsla.join(",") + ")"; - }; - var hsl2css_1 = hsl2css; - var unpack$5 = utils.unpack; - var rgb2hsl = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$5(args, "rgba"); - var r = args[0]; - var g = args[1]; - var b = args[2]; - r /= 255; - g /= 255; - b /= 255; - var min2 = Math.min(r, g, b); - var max2 = Math.max(r, g, b); - var l = (max2 + min2) / 2; - var s, h; - if (max2 === min2) { - s = 0; - h = Number.NaN; - } else { - s = l < 0.5 ? (max2 - min2) / (max2 + min2) : (max2 - min2) / (2 - max2 - min2); - } - if (r == max2) { - h = (g - b) / (max2 - min2); - } else if (g == max2) { - h = 2 + (b - r) / (max2 - min2); - } else if (b == max2) { - h = 4 + (r - g) / (max2 - min2); - } - h *= 60; - if (h < 0) { - h += 360; - } - if (args.length > 3 && args[3] !== void 0) { - return [h, s, l, args[3]]; - } - return [h, s, l]; - }; - var rgb2hsl_1 = rgb2hsl; - var unpack$6 = utils.unpack; - var last$3 = utils.last; - var round = Math.round; - var rgb2css = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var rgba = unpack$6(args, "rgba"); - var mode = last$3(args) || "rgb"; - if (mode.substr(0, 3) == "hsl") { - return hsl2css_1(rgb2hsl_1(rgba), mode); - } - rgba[0] = round(rgba[0]); - rgba[1] = round(rgba[1]); - rgba[2] = round(rgba[2]); - if (mode === "rgba" || rgba.length > 3 && rgba[3] < 1) { - rgba[3] = rgba.length > 3 ? rgba[3] : 1; - mode = "rgba"; - } - return mode + "(" + rgba.slice(0, mode === "rgb" ? 3 : 4).join(",") + ")"; - }; - var rgb2css_1 = rgb2css; - var unpack$7 = utils.unpack; - var round$1 = Math.round; - var hsl2rgb = function() { - var assign; - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$7(args, "hsl"); - var h = args[0]; - var s = args[1]; - var l = args[2]; - var r, g, b; - if (s === 0) { - r = g = b = l * 255; - } else { - var t3 = [0, 0, 0]; - var c = [0, 0, 0]; - var t2 = l < 0.5 ? l * (1 + s) : l + s - l * s; - var t1 = 2 * l - t2; - var h_ = h / 360; - t3[0] = h_ + 1 / 3; - t3[1] = h_; - t3[2] = h_ - 1 / 3; - for (var i2 = 0; i2 < 3; i2++) { - if (t3[i2] < 0) { - t3[i2] += 1; - } - if (t3[i2] > 1) { - t3[i2] -= 1; - } - if (6 * t3[i2] < 1) { - c[i2] = t1 + (t2 - t1) * 6 * t3[i2]; - } else if (2 * t3[i2] < 1) { - c[i2] = t2; - } else if (3 * t3[i2] < 2) { - c[i2] = t1 + (t2 - t1) * (2 / 3 - t3[i2]) * 6; - } else { - c[i2] = t1; - } - } - assign = [round$1(c[0] * 255), round$1(c[1] * 255), round$1(c[2] * 255)], r = assign[0], g = assign[1], b = assign[2]; - } - if (args.length > 3) { - return [r, g, b, args[3]]; - } - return [r, g, b, 1]; - }; - var hsl2rgb_1 = hsl2rgb; - var RE_RGB = /^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/; - var RE_RGBA = /^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/; - var RE_RGB_PCT = /^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/; - var RE_RGBA_PCT = /^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/; - var RE_HSL = /^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/; - var RE_HSLA = /^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/; - var round$2 = Math.round; - var css2rgb = function(css) { - css = css.toLowerCase().trim(); - var m; - if (input.format.named) { - try { - return input.format.named(css); - } catch (e) { - } - } - if (m = css.match(RE_RGB)) { - var rgb = m.slice(1, 4); - for (var i2 = 0; i2 < 3; i2++) { - rgb[i2] = +rgb[i2]; - } - rgb[3] = 1; - return rgb; - } - if (m = css.match(RE_RGBA)) { - var rgb$12 = m.slice(1, 5); - for (var i$12 = 0; i$12 < 4; i$12++) { - rgb$12[i$12] = +rgb$12[i$12]; - } - return rgb$12; - } - if (m = css.match(RE_RGB_PCT)) { - var rgb$2 = m.slice(1, 4); - for (var i$2 = 0; i$2 < 3; i$2++) { - rgb$2[i$2] = round$2(rgb$2[i$2] * 2.55); - } - rgb$2[3] = 1; - return rgb$2; - } - if (m = css.match(RE_RGBA_PCT)) { - var rgb$3 = m.slice(1, 5); - for (var i$3 = 0; i$3 < 3; i$3++) { - rgb$3[i$3] = round$2(rgb$3[i$3] * 2.55); - } - rgb$3[3] = +rgb$3[3]; - return rgb$3; - } - if (m = css.match(RE_HSL)) { - var hsl = m.slice(1, 4); - hsl[1] *= 0.01; - hsl[2] *= 0.01; - var rgb$4 = hsl2rgb_1(hsl); - rgb$4[3] = 1; - return rgb$4; - } - if (m = css.match(RE_HSLA)) { - var hsl$12 = m.slice(1, 4); - hsl$12[1] *= 0.01; - hsl$12[2] *= 0.01; - var rgb$5 = hsl2rgb_1(hsl$12); - rgb$5[3] = +m[4]; - return rgb$5; - } - }; - css2rgb.test = function(s) { - return RE_RGB.test(s) || RE_RGBA.test(s) || RE_RGB_PCT.test(s) || RE_RGBA_PCT.test(s) || RE_HSL.test(s) || RE_HSLA.test(s); - }; - var css2rgb_1 = css2rgb; - var type$3 = utils.type; - Color_1.prototype.css = function(mode) { - return rgb2css_1(this._rgb, mode); - }; - chroma_1.css = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["css"])))(); - }; - input.format.css = css2rgb_1; - input.autodetect.push({ - p: 5, - test: function(h) { - var rest = [], len = arguments.length - 1; - while (len-- > 0) - rest[len] = arguments[len + 1]; - if (!rest.length && type$3(h) === "string" && css2rgb_1.test(h)) { - return "css"; - } - } - }); - var unpack$8 = utils.unpack; - input.format.gl = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var rgb = unpack$8(args, "rgba"); - rgb[0] *= 255; - rgb[1] *= 255; - rgb[2] *= 255; - return rgb; - }; - chroma_1.gl = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["gl"])))(); - }; - Color_1.prototype.gl = function() { - var rgb = this._rgb; - return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, rgb[3]]; - }; - var unpack$9 = utils.unpack; - var rgb2hcg = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$9(args, "rgb"); - var r = ref[0]; - var g = ref[1]; - var b = ref[2]; - var min2 = Math.min(r, g, b); - var max2 = Math.max(r, g, b); - var delta = max2 - min2; - var c = delta * 100 / 255; - var _g = min2 / (255 - delta) * 100; - var h; - if (delta === 0) { - h = Number.NaN; - } else { - if (r === max2) { - h = (g - b) / delta; - } - if (g === max2) { - h = 2 + (b - r) / delta; - } - if (b === max2) { - h = 4 + (r - g) / delta; - } - h *= 60; - if (h < 0) { - h += 360; - } - } - return [h, c, _g]; - }; - var rgb2hcg_1 = rgb2hcg; - var unpack$a = utils.unpack; - var floor = Math.floor; - var hcg2rgb = function() { - var assign, assign$1, assign$2, assign$3, assign$4, assign$5; - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$a(args, "hcg"); - var h = args[0]; - var c = args[1]; - var _g = args[2]; - var r, g, b; - _g = _g * 255; - var _c = c * 255; - if (c === 0) { - r = g = b = _g; - } else { - if (h === 360) { - h = 0; - } - if (h > 360) { - h -= 360; - } - if (h < 0) { - h += 360; - } - h /= 60; - var i2 = floor(h); - var f = h - i2; - var p = _g * (1 - c); - var q = p + _c * (1 - f); - var t = p + _c * f; - var v = p + _c; - switch (i2) { - case 0: - assign = [v, t, p], r = assign[0], g = assign[1], b = assign[2]; - break; - case 1: - assign$1 = [q, v, p], r = assign$1[0], g = assign$1[1], b = assign$1[2]; - break; - case 2: - assign$2 = [p, v, t], r = assign$2[0], g = assign$2[1], b = assign$2[2]; - break; - case 3: - assign$3 = [p, q, v], r = assign$3[0], g = assign$3[1], b = assign$3[2]; - break; - case 4: - assign$4 = [t, p, v], r = assign$4[0], g = assign$4[1], b = assign$4[2]; - break; - case 5: - assign$5 = [v, p, q], r = assign$5[0], g = assign$5[1], b = assign$5[2]; - break; - } - } - return [r, g, b, args.length > 3 ? args[3] : 1]; - }; - var hcg2rgb_1 = hcg2rgb; - var unpack$b = utils.unpack; - var type$4 = utils.type; - Color_1.prototype.hcg = function() { - return rgb2hcg_1(this._rgb); - }; - chroma_1.hcg = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["hcg"])))(); - }; - input.format.hcg = hcg2rgb_1; - input.autodetect.push({ - p: 1, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$b(args, "hcg"); - if (type$4(args) === "array" && args.length === 3) { - return "hcg"; - } - } - }); - var unpack$c = utils.unpack; - var last$4 = utils.last; - var round$3 = Math.round; - var rgb2hex = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$c(args, "rgba"); - var r = ref[0]; - var g = ref[1]; - var b = ref[2]; - var a = ref[3]; - var mode = last$4(args) || "auto"; - if (a === void 0) { - a = 1; - } - if (mode === "auto") { - mode = a < 1 ? "rgba" : "rgb"; - } - r = round$3(r); - g = round$3(g); - b = round$3(b); - var u = r << 16 | g << 8 | b; - var str = "000000" + u.toString(16); - str = str.substr(str.length - 6); - var hxa = "0" + round$3(a * 255).toString(16); - hxa = hxa.substr(hxa.length - 2); - switch (mode.toLowerCase()) { - case "rgba": - return "#" + str + hxa; - case "argb": - return "#" + hxa + str; - default: - return "#" + str; - } - }; - var rgb2hex_1 = rgb2hex; - var RE_HEX = /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/; - var RE_HEXA = /^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/; - var hex2rgb = function(hex) { - if (hex.match(RE_HEX)) { - if (hex.length === 4 || hex.length === 7) { - hex = hex.substr(1); - } - if (hex.length === 3) { - hex = hex.split(""); - hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; - } - var u = parseInt(hex, 16); - var r = u >> 16; - var g = u >> 8 & 255; - var b = u & 255; - return [r, g, b, 1]; - } - if (hex.match(RE_HEXA)) { - if (hex.length === 5 || hex.length === 9) { - hex = hex.substr(1); - } - if (hex.length === 4) { - hex = hex.split(""); - hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]; - } - var u$1 = parseInt(hex, 16); - var r$1 = u$1 >> 24 & 255; - var g$1 = u$1 >> 16 & 255; - var b$1 = u$1 >> 8 & 255; - var a = Math.round((u$1 & 255) / 255 * 100) / 100; - return [r$1, g$1, b$1, a]; - } - throw new Error("unknown hex color: " + hex); - }; - var hex2rgb_1 = hex2rgb; - var type$5 = utils.type; - Color_1.prototype.hex = function(mode) { - return rgb2hex_1(this._rgb, mode); - }; - chroma_1.hex = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["hex"])))(); - }; - input.format.hex = hex2rgb_1; - input.autodetect.push({ - p: 4, - test: function(h) { - var rest = [], len = arguments.length - 1; - while (len-- > 0) - rest[len] = arguments[len + 1]; - if (!rest.length && type$5(h) === "string" && [3, 4, 5, 6, 7, 8, 9].indexOf(h.length) >= 0) { - return "hex"; - } - } - }); - var unpack$d = utils.unpack; - var TWOPI = utils.TWOPI; - var min = Math.min; - var sqrt = Math.sqrt; - var acos = Math.acos; - var rgb2hsi = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$d(args, "rgb"); - var r = ref[0]; - var g = ref[1]; - var b = ref[2]; - r /= 255; - g /= 255; - b /= 255; - var h; - var min_ = min(r, g, b); - var i2 = (r + g + b) / 3; - var s = i2 > 0 ? 1 - min_ / i2 : 0; - if (s === 0) { - h = NaN; - } else { - h = (r - g + (r - b)) / 2; - h /= sqrt((r - g) * (r - g) + (r - b) * (g - b)); - h = acos(h); - if (b > g) { - h = TWOPI - h; - } - h /= TWOPI; - } - return [h * 360, s, i2]; - }; - var rgb2hsi_1 = rgb2hsi; - var unpack$e = utils.unpack; - var limit$1 = utils.limit; - var TWOPI$1 = utils.TWOPI; - var PITHIRD = utils.PITHIRD; - var cos = Math.cos; - var hsi2rgb = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$e(args, "hsi"); - var h = args[0]; - var s = args[1]; - var i2 = args[2]; - var r, g, b; - if (isNaN(h)) { - h = 0; - } - if (isNaN(s)) { - s = 0; - } - if (h > 360) { - h -= 360; - } - if (h < 0) { - h += 360; - } - h /= 360; - if (h < 1 / 3) { - b = (1 - s) / 3; - r = (1 + s * cos(TWOPI$1 * h) / cos(PITHIRD - TWOPI$1 * h)) / 3; - g = 1 - (b + r); - } else if (h < 2 / 3) { - h -= 1 / 3; - r = (1 - s) / 3; - g = (1 + s * cos(TWOPI$1 * h) / cos(PITHIRD - TWOPI$1 * h)) / 3; - b = 1 - (r + g); - } else { - h -= 2 / 3; - g = (1 - s) / 3; - b = (1 + s * cos(TWOPI$1 * h) / cos(PITHIRD - TWOPI$1 * h)) / 3; - r = 1 - (g + b); - } - r = limit$1(i2 * r * 3); - g = limit$1(i2 * g * 3); - b = limit$1(i2 * b * 3); - return [r * 255, g * 255, b * 255, args.length > 3 ? args[3] : 1]; - }; - var hsi2rgb_1 = hsi2rgb; - var unpack$f = utils.unpack; - var type$6 = utils.type; - Color_1.prototype.hsi = function() { - return rgb2hsi_1(this._rgb); - }; - chroma_1.hsi = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["hsi"])))(); - }; - input.format.hsi = hsi2rgb_1; - input.autodetect.push({ - p: 2, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$f(args, "hsi"); - if (type$6(args) === "array" && args.length === 3) { - return "hsi"; - } - } - }); - var unpack$g = utils.unpack; - var type$7 = utils.type; - Color_1.prototype.hsl = function() { - return rgb2hsl_1(this._rgb); - }; - chroma_1.hsl = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["hsl"])))(); - }; - input.format.hsl = hsl2rgb_1; - input.autodetect.push({ - p: 2, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$g(args, "hsl"); - if (type$7(args) === "array" && args.length === 3) { - return "hsl"; - } - } - }); - var unpack$h = utils.unpack; - var min$1 = Math.min; - var max$1 = Math.max; - var rgb2hsl$1 = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$h(args, "rgb"); - var r = args[0]; - var g = args[1]; - var b = args[2]; - var min_ = min$1(r, g, b); - var max_ = max$1(r, g, b); - var delta = max_ - min_; - var h, s, v; - v = max_ / 255; - if (max_ === 0) { - h = Number.NaN; - s = 0; - } else { - s = delta / max_; - if (r === max_) { - h = (g - b) / delta; - } - if (g === max_) { - h = 2 + (b - r) / delta; - } - if (b === max_) { - h = 4 + (r - g) / delta; - } - h *= 60; - if (h < 0) { - h += 360; - } - } - return [h, s, v]; - }; - var rgb2hsv = rgb2hsl$1; - var unpack$i = utils.unpack; - var floor$1 = Math.floor; - var hsv2rgb = function() { - var assign, assign$1, assign$2, assign$3, assign$4, assign$5; - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$i(args, "hsv"); - var h = args[0]; - var s = args[1]; - var v = args[2]; - var r, g, b; - v *= 255; - if (s === 0) { - r = g = b = v; - } else { - if (h === 360) { - h = 0; - } - if (h > 360) { - h -= 360; - } - if (h < 0) { - h += 360; - } - h /= 60; - var i2 = floor$1(h); - var f = h - i2; - var p = v * (1 - s); - var q = v * (1 - s * f); - var t = v * (1 - s * (1 - f)); - switch (i2) { - case 0: - assign = [v, t, p], r = assign[0], g = assign[1], b = assign[2]; - break; - case 1: - assign$1 = [q, v, p], r = assign$1[0], g = assign$1[1], b = assign$1[2]; - break; - case 2: - assign$2 = [p, v, t], r = assign$2[0], g = assign$2[1], b = assign$2[2]; - break; - case 3: - assign$3 = [p, q, v], r = assign$3[0], g = assign$3[1], b = assign$3[2]; - break; - case 4: - assign$4 = [t, p, v], r = assign$4[0], g = assign$4[1], b = assign$4[2]; - break; - case 5: - assign$5 = [v, p, q], r = assign$5[0], g = assign$5[1], b = assign$5[2]; - break; - } - } - return [r, g, b, args.length > 3 ? args[3] : 1]; - }; - var hsv2rgb_1 = hsv2rgb; - var unpack$j = utils.unpack; - var type$8 = utils.type; - Color_1.prototype.hsv = function() { - return rgb2hsv(this._rgb); - }; - chroma_1.hsv = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["hsv"])))(); - }; - input.format.hsv = hsv2rgb_1; - input.autodetect.push({ - p: 2, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$j(args, "hsv"); - if (type$8(args) === "array" && args.length === 3) { - return "hsv"; - } - } - }); - var labConstants = { - Kn: 18, - Xn: 0.95047, - Yn: 1, - Zn: 1.08883, - t0: 0.137931034, - t1: 0.206896552, - t2: 0.12841855, - t3: 8856452e-9 - }; - var unpack$k = utils.unpack; - var pow = Math.pow; - var rgb2lab = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$k(args, "rgb"); - var r = ref[0]; - var g = ref[1]; - var b = ref[2]; - var ref$1 = rgb2xyz(r, g, b); - var x = ref$1[0]; - var y = ref$1[1]; - var z = ref$1[2]; - var l = 116 * y - 16; - return [l < 0 ? 0 : l, 500 * (x - y), 200 * (y - z)]; - }; - var rgb_xyz = function(r) { - if ((r /= 255) <= 0.04045) { - return r / 12.92; - } - return pow((r + 0.055) / 1.055, 2.4); - }; - var xyz_lab = function(t) { - if (t > labConstants.t3) { - return pow(t, 1 / 3); - } - return t / labConstants.t2 + labConstants.t0; - }; - var rgb2xyz = function(r, g, b) { - r = rgb_xyz(r); - g = rgb_xyz(g); - b = rgb_xyz(b); - var x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / labConstants.Xn); - var y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.072175 * b) / labConstants.Yn); - var z = xyz_lab((0.0193339 * r + 0.119192 * g + 0.9503041 * b) / labConstants.Zn); - return [x, y, z]; - }; - var rgb2lab_1 = rgb2lab; - var unpack$l = utils.unpack; - var pow$1 = Math.pow; - var lab2rgb = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$l(args, "lab"); - var l = args[0]; - var a = args[1]; - var b = args[2]; - var x, y, z, r, g, b_; - y = (l + 16) / 116; - x = isNaN(a) ? y : y + a / 500; - z = isNaN(b) ? y : y - b / 200; - y = labConstants.Yn * lab_xyz(y); - x = labConstants.Xn * lab_xyz(x); - z = labConstants.Zn * lab_xyz(z); - r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z); - g = xyz_rgb(-0.969266 * x + 1.8760108 * y + 0.041556 * z); - b_ = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z); - return [r, g, b_, args.length > 3 ? args[3] : 1]; - }; - var xyz_rgb = function(r) { - return 255 * (r <= 304e-5 ? 12.92 * r : 1.055 * pow$1(r, 1 / 2.4) - 0.055); - }; - var lab_xyz = function(t) { - return t > labConstants.t1 ? t * t * t : labConstants.t2 * (t - labConstants.t0); - }; - var lab2rgb_1 = lab2rgb; - var unpack$m = utils.unpack; - var type$9 = utils.type; - Color_1.prototype.lab = function() { - return rgb2lab_1(this._rgb); - }; - chroma_1.lab = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["lab"])))(); - }; - input.format.lab = lab2rgb_1; - input.autodetect.push({ - p: 2, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$m(args, "lab"); - if (type$9(args) === "array" && args.length === 3) { - return "lab"; - } - } - }); - var unpack$n = utils.unpack; - var RAD2DEG = utils.RAD2DEG; - var sqrt$1 = Math.sqrt; - var atan2 = Math.atan2; - var round$4 = Math.round; - var lab2lch = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$n(args, "lab"); - var l = ref[0]; - var a = ref[1]; - var b = ref[2]; - var c = sqrt$1(a * a + b * b); - var h = (atan2(b, a) * RAD2DEG + 360) % 360; - if (round$4(c * 1e4) === 0) { - h = Number.NaN; - } - return [l, c, h]; - }; - var lab2lch_1 = lab2lch; - var unpack$o = utils.unpack; - var rgb2lch = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$o(args, "rgb"); - var r = ref[0]; - var g = ref[1]; - var b = ref[2]; - var ref$1 = rgb2lab_1(r, g, b); - var l = ref$1[0]; - var a = ref$1[1]; - var b_ = ref$1[2]; - return lab2lch_1(l, a, b_); - }; - var rgb2lch_1 = rgb2lch; - var unpack$p = utils.unpack; - var DEG2RAD = utils.DEG2RAD; - var sin = Math.sin; - var cos$1 = Math.cos; - var lch2lab = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$p(args, "lch"); - var l = ref[0]; - var c = ref[1]; - var h = ref[2]; - if (isNaN(h)) { - h = 0; - } - h = h * DEG2RAD; - return [l, cos$1(h) * c, sin(h) * c]; - }; - var lch2lab_1 = lch2lab; - var unpack$q = utils.unpack; - var lch2rgb = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$q(args, "lch"); - var l = args[0]; - var c = args[1]; - var h = args[2]; - var ref = lch2lab_1(l, c, h); - var L = ref[0]; - var a = ref[1]; - var b_ = ref[2]; - var ref$1 = lab2rgb_1(L, a, b_); - var r = ref$1[0]; - var g = ref$1[1]; - var b = ref$1[2]; - return [r, g, b, args.length > 3 ? args[3] : 1]; - }; - var lch2rgb_1 = lch2rgb; - var unpack$r = utils.unpack; - var hcl2rgb = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var hcl = unpack$r(args, "hcl").reverse(); - return lch2rgb_1.apply(void 0, hcl); - }; - var hcl2rgb_1 = hcl2rgb; - var unpack$s = utils.unpack; - var type$a = utils.type; - Color_1.prototype.lch = function() { - return rgb2lch_1(this._rgb); - }; - Color_1.prototype.hcl = function() { - return rgb2lch_1(this._rgb).reverse(); - }; - chroma_1.lch = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["lch"])))(); - }; - chroma_1.hcl = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["hcl"])))(); - }; - input.format.lch = lch2rgb_1; - input.format.hcl = hcl2rgb_1; - ["lch", "hcl"].forEach(function(m) { - return input.autodetect.push({ - p: 2, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$s(args, m); - if (type$a(args) === "array" && args.length === 3) { - return m; - } - } - }); - }); - var w3cx11 = { - aliceblue: "#f0f8ff", - antiquewhite: "#faebd7", - aqua: "#00ffff", - aquamarine: "#7fffd4", - azure: "#f0ffff", - beige: "#f5f5dc", - bisque: "#ffe4c4", - black: "#000000", - blanchedalmond: "#ffebcd", - blue: "#0000ff", - blueviolet: "#8a2be2", - brown: "#a52a2a", - burlywood: "#deb887", - cadetblue: "#5f9ea0", - chartreuse: "#7fff00", - chocolate: "#d2691e", - coral: "#ff7f50", - cornflower: "#6495ed", - cornflowerblue: "#6495ed", - cornsilk: "#fff8dc", - crimson: "#dc143c", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgoldenrod: "#b8860b", - darkgray: "#a9a9a9", - darkgreen: "#006400", - darkgrey: "#a9a9a9", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkseagreen: "#8fbc8f", - darkslateblue: "#483d8b", - darkslategray: "#2f4f4f", - darkslategrey: "#2f4f4f", - darkturquoise: "#00ced1", - darkviolet: "#9400d3", - deeppink: "#ff1493", - deepskyblue: "#00bfff", - dimgray: "#696969", - dimgrey: "#696969", - dodgerblue: "#1e90ff", - firebrick: "#b22222", - floralwhite: "#fffaf0", - forestgreen: "#228b22", - fuchsia: "#ff00ff", - gainsboro: "#dcdcdc", - ghostwhite: "#f8f8ff", - gold: "#ffd700", - goldenrod: "#daa520", - gray: "#808080", - green: "#008000", - greenyellow: "#adff2f", - grey: "#808080", - honeydew: "#f0fff0", - hotpink: "#ff69b4", - indianred: "#cd5c5c", - indigo: "#4b0082", - ivory: "#fffff0", - khaki: "#f0e68c", - laserlemon: "#ffff54", - lavender: "#e6e6fa", - lavenderblush: "#fff0f5", - lawngreen: "#7cfc00", - lemonchiffon: "#fffacd", - lightblue: "#add8e6", - lightcoral: "#f08080", - lightcyan: "#e0ffff", - lightgoldenrod: "#fafad2", - lightgoldenrodyellow: "#fafad2", - lightgray: "#d3d3d3", - lightgreen: "#90ee90", - lightgrey: "#d3d3d3", - lightpink: "#ffb6c1", - lightsalmon: "#ffa07a", - lightseagreen: "#20b2aa", - lightskyblue: "#87cefa", - lightslategray: "#778899", - lightslategrey: "#778899", - lightsteelblue: "#b0c4de", - lightyellow: "#ffffe0", - lime: "#00ff00", - limegreen: "#32cd32", - linen: "#faf0e6", - magenta: "#ff00ff", - maroon: "#800000", - maroon2: "#7f0000", - maroon3: "#b03060", - mediumaquamarine: "#66cdaa", - mediumblue: "#0000cd", - mediumorchid: "#ba55d3", - mediumpurple: "#9370db", - mediumseagreen: "#3cb371", - mediumslateblue: "#7b68ee", - mediumspringgreen: "#00fa9a", - mediumturquoise: "#48d1cc", - mediumvioletred: "#c71585", - midnightblue: "#191970", - mintcream: "#f5fffa", - mistyrose: "#ffe4e1", - moccasin: "#ffe4b5", - navajowhite: "#ffdead", - navy: "#000080", - oldlace: "#fdf5e6", - olive: "#808000", - olivedrab: "#6b8e23", - orange: "#ffa500", - orangered: "#ff4500", - orchid: "#da70d6", - palegoldenrod: "#eee8aa", - palegreen: "#98fb98", - paleturquoise: "#afeeee", - palevioletred: "#db7093", - papayawhip: "#ffefd5", - peachpuff: "#ffdab9", - peru: "#cd853f", - pink: "#ffc0cb", - plum: "#dda0dd", - powderblue: "#b0e0e6", - purple: "#800080", - purple2: "#7f007f", - purple3: "#a020f0", - rebeccapurple: "#663399", - red: "#ff0000", - rosybrown: "#bc8f8f", - royalblue: "#4169e1", - saddlebrown: "#8b4513", - salmon: "#fa8072", - sandybrown: "#f4a460", - seagreen: "#2e8b57", - seashell: "#fff5ee", - sienna: "#a0522d", - silver: "#c0c0c0", - skyblue: "#87ceeb", - slateblue: "#6a5acd", - slategray: "#708090", - slategrey: "#708090", - snow: "#fffafa", - springgreen: "#00ff7f", - steelblue: "#4682b4", - tan: "#d2b48c", - teal: "#008080", - thistle: "#d8bfd8", - tomato: "#ff6347", - turquoise: "#40e0d0", - violet: "#ee82ee", - wheat: "#f5deb3", - white: "#ffffff", - whitesmoke: "#f5f5f5", - yellow: "#ffff00", - yellowgreen: "#9acd32" - }; - var w3cx11_1 = w3cx11; - var type$b = utils.type; - Color_1.prototype.name = function() { - var hex = rgb2hex_1(this._rgb, "rgb"); - for (var i2 = 0, list2 = Object.keys(w3cx11_1); i2 < list2.length; i2 += 1) { - var n = list2[i2]; - if (w3cx11_1[n] === hex) { - return n.toLowerCase(); - } - } - return hex; - }; - input.format.named = function(name2) { - name2 = name2.toLowerCase(); - if (w3cx11_1[name2]) { - return hex2rgb_1(w3cx11_1[name2]); - } - throw new Error("unknown color name: " + name2); - }; - input.autodetect.push({ - p: 5, - test: function(h) { - var rest = [], len = arguments.length - 1; - while (len-- > 0) - rest[len] = arguments[len + 1]; - if (!rest.length && type$b(h) === "string" && w3cx11_1[h.toLowerCase()]) { - return "named"; - } - } - }); - var unpack$t = utils.unpack; - var rgb2num = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var ref = unpack$t(args, "rgb"); - var r = ref[0]; - var g = ref[1]; - var b = ref[2]; - return (r << 16) + (g << 8) + b; - }; - var rgb2num_1 = rgb2num; - var type$c = utils.type; - var num2rgb = function(num) { - if (type$c(num) == "number" && num >= 0 && num <= 16777215) { - var r = num >> 16; - var g = num >> 8 & 255; - var b = num & 255; - return [r, g, b, 1]; - } - throw new Error("unknown num color: " + num); - }; - var num2rgb_1 = num2rgb; - var type$d = utils.type; - Color_1.prototype.num = function() { - return rgb2num_1(this._rgb); - }; - chroma_1.num = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["num"])))(); - }; - input.format.num = num2rgb_1; - input.autodetect.push({ - p: 5, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - if (args.length === 1 && type$d(args[0]) === "number" && args[0] >= 0 && args[0] <= 16777215) { - return "num"; - } - } - }); - var unpack$u = utils.unpack; - var type$e = utils.type; - var round$5 = Math.round; - Color_1.prototype.rgb = function(rnd2) { - if (rnd2 === void 0) - rnd2 = true; - if (rnd2 === false) { - return this._rgb.slice(0, 3); - } - return this._rgb.slice(0, 3).map(round$5); - }; - Color_1.prototype.rgba = function(rnd2) { - if (rnd2 === void 0) - rnd2 = true; - return this._rgb.slice(0, 4).map(function(v, i2) { - return i2 < 3 ? rnd2 === false ? v : round$5(v) : v; - }); - }; - chroma_1.rgb = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["rgb"])))(); - }; - input.format.rgb = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var rgba = unpack$u(args, "rgba"); - if (rgba[3] === void 0) { - rgba[3] = 1; - } - return rgba; - }; - input.autodetect.push({ - p: 3, - test: function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - args = unpack$u(args, "rgba"); - if (type$e(args) === "array" && (args.length === 3 || args.length === 4 && type$e(args[3]) == "number" && args[3] >= 0 && args[3] <= 1)) { - return "rgb"; - } - } - }); - var log = Math.log; - var temperature2rgb = function(kelvin) { - var temp = kelvin / 100; - var r, g, b; - if (temp < 66) { - r = 255; - g = -155.25485562709179 - 0.44596950469579133 * (g = temp - 2) + 104.49216199393888 * log(g); - b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp - 10) + 115.67994401066147 * log(b); - } else { - r = 351.97690566805693 + 0.114206453784165 * (r = temp - 55) - 40.25366309332127 * log(r); - g = 325.4494125711974 + 0.07943456536662342 * (g = temp - 50) - 28.0852963507957 * log(g); - b = 255; - } - return [r, g, b, 1]; - }; - var temperature2rgb_1 = temperature2rgb; - var unpack$v = utils.unpack; - var round$6 = Math.round; - var rgb2temperature = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - var rgb = unpack$v(args, "rgb"); - var r = rgb[0], b = rgb[2]; - var minTemp = 1e3; - var maxTemp = 4e4; - var eps = 0.4; - var temp; - while (maxTemp - minTemp > eps) { - temp = (maxTemp + minTemp) * 0.5; - var rgb$12 = temperature2rgb_1(temp); - if (rgb$12[2] / rgb$12[0] >= b / r) { - maxTemp = temp; - } else { - minTemp = temp; - } - } - return round$6(temp); - }; - var rgb2temperature_1 = rgb2temperature; - Color_1.prototype.temp = Color_1.prototype.kelvin = Color_1.prototype.temperature = function() { - return rgb2temperature_1(this._rgb); - }; - chroma_1.temp = chroma_1.kelvin = chroma_1.temperature = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - return new (Function.prototype.bind.apply(Color_1, [null].concat(args, ["temp"])))(); - }; - input.format.temp = input.format.kelvin = input.format.temperature = temperature2rgb_1; - var type$f = utils.type; - Color_1.prototype.alpha = function(a, mutate) { - if (mutate === void 0) - mutate = false; - if (a !== void 0 && type$f(a) === "number") { - if (mutate) { - this._rgb[3] = a; - return this; - } - return new Color_1([this._rgb[0], this._rgb[1], this._rgb[2], a], "rgb"); - } - return this._rgb[3]; - }; - Color_1.prototype.clipped = function() { - return this._rgb._clipped || false; - }; - Color_1.prototype.darken = function(amount) { - if (amount === void 0) - amount = 1; - var me = this; - var lab = me.lab(); - lab[0] -= labConstants.Kn * amount; - return new Color_1(lab, "lab").alpha(me.alpha(), true); - }; - Color_1.prototype.brighten = function(amount) { - if (amount === void 0) - amount = 1; - return this.darken(-amount); - }; - Color_1.prototype.darker = Color_1.prototype.darken; - Color_1.prototype.brighter = Color_1.prototype.brighten; - Color_1.prototype.get = function(mc) { - var ref = mc.split("."); - var mode = ref[0]; - var channel = ref[1]; - var src = this[mode](); - if (channel) { - var i2 = mode.indexOf(channel); - if (i2 > -1) { - return src[i2]; - } - throw new Error("unknown channel " + channel + " in mode " + mode); - } else { - return src; - } - }; - var type$g = utils.type; - var pow$2 = Math.pow; - var EPS = 1e-7; - var MAX_ITER = 20; - Color_1.prototype.luminance = function(lum) { - if (lum !== void 0 && type$g(lum) === "number") { - if (lum === 0) { - return new Color_1([0, 0, 0, this._rgb[3]], "rgb"); - } - if (lum === 1) { - return new Color_1([255, 255, 255, this._rgb[3]], "rgb"); - } - var cur_lum = this.luminance(); - var mode = "rgb"; - var max_iter = MAX_ITER; - var test = function(low, high) { - var mid = low.interpolate(high, 0.5, mode); - var lm = mid.luminance(); - if (Math.abs(lum - lm) < EPS || !max_iter--) { - return mid; - } - return lm > lum ? test(low, mid) : test(mid, high); - }; - var rgb = (cur_lum > lum ? test(new Color_1([0, 0, 0]), this) : test(this, new Color_1([255, 255, 255]))).rgb(); - return new Color_1(rgb.concat([this._rgb[3]])); - } - return rgb2luminance.apply(void 0, this._rgb.slice(0, 3)); - }; - var rgb2luminance = function(r, g, b) { - r = luminance_x(r); - g = luminance_x(g); - b = luminance_x(b); - return 0.2126 * r + 0.7152 * g + 0.0722 * b; - }; - var luminance_x = function(x) { - x /= 255; - return x <= 0.03928 ? x / 12.92 : pow$2((x + 0.055) / 1.055, 2.4); - }; - var interpolator = {}; - var type$h = utils.type; - var mix = function(col1, col2, f) { - if (f === void 0) - f = 0.5; - var rest = [], len = arguments.length - 3; - while (len-- > 0) - rest[len] = arguments[len + 3]; - var mode = rest[0] || "lrgb"; - if (!interpolator[mode] && !rest.length) { - mode = Object.keys(interpolator)[0]; - } - if (!interpolator[mode]) { - throw new Error("interpolation mode " + mode + " is not defined"); - } - if (type$h(col1) !== "object") { - col1 = new Color_1(col1); - } - if (type$h(col2) !== "object") { - col2 = new Color_1(col2); - } - return interpolator[mode](col1, col2, f).alpha(col1.alpha() + f * (col2.alpha() - col1.alpha())); - }; - Color_1.prototype.mix = Color_1.prototype.interpolate = function(col2, f) { - if (f === void 0) - f = 0.5; - var rest = [], len = arguments.length - 2; - while (len-- > 0) - rest[len] = arguments[len + 2]; - return mix.apply(void 0, [this, col2, f].concat(rest)); - }; - Color_1.prototype.premultiply = function(mutate) { - if (mutate === void 0) - mutate = false; - var rgb = this._rgb; - var a = rgb[3]; - if (mutate) { - this._rgb = [rgb[0] * a, rgb[1] * a, rgb[2] * a, a]; - return this; - } else { - return new Color_1([rgb[0] * a, rgb[1] * a, rgb[2] * a, a], "rgb"); - } - }; - Color_1.prototype.saturate = function(amount) { - if (amount === void 0) - amount = 1; - var me = this; - var lch = me.lch(); - lch[1] += labConstants.Kn * amount; - if (lch[1] < 0) { - lch[1] = 0; - } - return new Color_1(lch, "lch").alpha(me.alpha(), true); - }; - Color_1.prototype.desaturate = function(amount) { - if (amount === void 0) - amount = 1; - return this.saturate(-amount); - }; - var type$i = utils.type; - Color_1.prototype.set = function(mc, value, mutate) { - if (mutate === void 0) - mutate = false; - var ref = mc.split("."); - var mode = ref[0]; - var channel = ref[1]; - var src = this[mode](); - if (channel) { - var i2 = mode.indexOf(channel); - if (i2 > -1) { - if (type$i(value) == "string") { - switch (value.charAt(0)) { - case "+": - src[i2] += +value; - break; - case "-": - src[i2] += +value; - break; - case "*": - src[i2] *= +value.substr(1); - break; - case "/": - src[i2] /= +value.substr(1); - break; - default: - src[i2] = +value; - } - } else if (type$i(value) === "number") { - src[i2] = value; - } else { - throw new Error("unsupported value for Color.set"); - } - var out = new Color_1(src, mode); - if (mutate) { - this._rgb = out._rgb; - return this; - } - return out; - } - throw new Error("unknown channel " + channel + " in mode " + mode); - } else { - return src; - } - }; - var rgb$1 = function(col1, col2, f) { - var xyz0 = col1._rgb; - var xyz1 = col2._rgb; - return new Color_1(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), "rgb"); - }; - interpolator.rgb = rgb$1; - var sqrt$2 = Math.sqrt; - var pow$3 = Math.pow; - var lrgb = function(col1, col2, f) { - var ref = col1._rgb; - var x1 = ref[0]; - var y1 = ref[1]; - var z1 = ref[2]; - var ref$1 = col2._rgb; - var x2 = ref$1[0]; - var y2 = ref$1[1]; - var z2 = ref$1[2]; - return new Color_1(sqrt$2(pow$3(x1, 2) * (1 - f) + pow$3(x2, 2) * f), sqrt$2(pow$3(y1, 2) * (1 - f) + pow$3(y2, 2) * f), sqrt$2(pow$3(z1, 2) * (1 - f) + pow$3(z2, 2) * f), "rgb"); - }; - interpolator.lrgb = lrgb; - var lab$1 = function(col1, col2, f) { - var xyz0 = col1.lab(); - var xyz1 = col2.lab(); - return new Color_1(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), "lab"); - }; - interpolator.lab = lab$1; - var _hsx = function(col1, col2, f, m) { - var assign, assign$1; - var xyz0, xyz1; - if (m === "hsl") { - xyz0 = col1.hsl(); - xyz1 = col2.hsl(); - } else if (m === "hsv") { - xyz0 = col1.hsv(); - xyz1 = col2.hsv(); - } else if (m === "hcg") { - xyz0 = col1.hcg(); - xyz1 = col2.hcg(); - } else if (m === "hsi") { - xyz0 = col1.hsi(); - xyz1 = col2.hsi(); - } else if (m === "lch" || m === "hcl") { - m = "hcl"; - xyz0 = col1.hcl(); - xyz1 = col2.hcl(); - } - var hue0, hue1, sat0, sat1, lbv0, lbv1; - if (m.substr(0, 1) === "h") { - assign = xyz0, hue0 = assign[0], sat0 = assign[1], lbv0 = assign[2]; - assign$1 = xyz1, hue1 = assign$1[0], sat1 = assign$1[1], lbv1 = assign$1[2]; - } - var sat, hue, lbv, dh; - if (!isNaN(hue0) && !isNaN(hue1)) { - if (hue1 > hue0 && hue1 - hue0 > 180) { - dh = hue1 - (hue0 + 360); - } else if (hue1 < hue0 && hue0 - hue1 > 180) { - dh = hue1 + 360 - hue0; - } else { - dh = hue1 - hue0; - } - hue = hue0 + f * dh; - } else if (!isNaN(hue0)) { - hue = hue0; - if ((lbv1 == 1 || lbv1 == 0) && m != "hsv") { - sat = sat0; - } - } else if (!isNaN(hue1)) { - hue = hue1; - if ((lbv0 == 1 || lbv0 == 0) && m != "hsv") { - sat = sat1; - } - } else { - hue = Number.NaN; - } - if (sat === void 0) { - sat = sat0 + f * (sat1 - sat0); - } - lbv = lbv0 + f * (lbv1 - lbv0); - return new Color_1([hue, sat, lbv], m); - }; - var lch$1 = function(col1, col2, f) { - return _hsx(col1, col2, f, "lch"); - }; - interpolator.lch = lch$1; - interpolator.hcl = lch$1; - var num$1 = function(col1, col2, f) { - var c1 = col1.num(); - var c2 = col2.num(); - return new Color_1(c1 + f * (c2 - c1), "num"); - }; - interpolator.num = num$1; - var hcg$1 = function(col1, col2, f) { - return _hsx(col1, col2, f, "hcg"); - }; - interpolator.hcg = hcg$1; - var hsi$1 = function(col1, col2, f) { - return _hsx(col1, col2, f, "hsi"); - }; - interpolator.hsi = hsi$1; - var hsl$1 = function(col1, col2, f) { - return _hsx(col1, col2, f, "hsl"); - }; - interpolator.hsl = hsl$1; - var hsv$1 = function(col1, col2, f) { - return _hsx(col1, col2, f, "hsv"); - }; - interpolator.hsv = hsv$1; - var clip_rgb$2 = utils.clip_rgb; - var pow$4 = Math.pow; - var sqrt$3 = Math.sqrt; - var PI$1 = Math.PI; - var cos$2 = Math.cos; - var sin$1 = Math.sin; - var atan2$1 = Math.atan2; - var average = function(colors, mode, weights) { - if (mode === void 0) - mode = "lrgb"; - if (weights === void 0) - weights = null; - var l = colors.length; - if (!weights) { - weights = Array.from(new Array(l)).map(function() { - return 1; - }); - } - var k = l / weights.reduce(function(a, b) { - return a + b; - }); - weights.forEach(function(w, i3) { - weights[i3] *= k; - }); - colors = colors.map(function(c) { - return new Color_1(c); - }); - if (mode === "lrgb") { - return _average_lrgb(colors, weights); - } - var first = colors.shift(); - var xyz = first.get(mode); - var cnt = []; - var dx = 0; - var dy = 0; - for (var i2 = 0; i2 < xyz.length; i2++) { - xyz[i2] = (xyz[i2] || 0) * weights[0]; - cnt.push(isNaN(xyz[i2]) ? 0 : weights[0]); - if (mode.charAt(i2) === "h" && !isNaN(xyz[i2])) { - var A = xyz[i2] / 180 * PI$1; - dx += cos$2(A) * weights[0]; - dy += sin$1(A) * weights[0]; - } - } - var alpha = first.alpha() * weights[0]; - colors.forEach(function(c, ci) { - var xyz2 = c.get(mode); - alpha += c.alpha() * weights[ci + 1]; - for (var i3 = 0; i3 < xyz.length; i3++) { - if (!isNaN(xyz2[i3])) { - cnt[i3] += weights[ci + 1]; - if (mode.charAt(i3) === "h") { - var A2 = xyz2[i3] / 180 * PI$1; - dx += cos$2(A2) * weights[ci + 1]; - dy += sin$1(A2) * weights[ci + 1]; - } else { - xyz[i3] += xyz2[i3] * weights[ci + 1]; - } - } - } - }); - for (var i$12 = 0; i$12 < xyz.length; i$12++) { - if (mode.charAt(i$12) === "h") { - var A$1 = atan2$1(dy / cnt[i$12], dx / cnt[i$12]) / PI$1 * 180; - while (A$1 < 0) { - A$1 += 360; - } - while (A$1 >= 360) { - A$1 -= 360; - } - xyz[i$12] = A$1; - } else { - xyz[i$12] = xyz[i$12] / cnt[i$12]; - } - } - alpha /= l; - return new Color_1(xyz, mode).alpha(alpha > 0.99999 ? 1 : alpha, true); - }; - var _average_lrgb = function(colors, weights) { - var l = colors.length; - var xyz = [0, 0, 0, 0]; - for (var i2 = 0; i2 < colors.length; i2++) { - var col = colors[i2]; - var f = weights[i2] / l; - var rgb = col._rgb; - xyz[0] += pow$4(rgb[0], 2) * f; - xyz[1] += pow$4(rgb[1], 2) * f; - xyz[2] += pow$4(rgb[2], 2) * f; - xyz[3] += rgb[3] * f; - } - xyz[0] = sqrt$3(xyz[0]); - xyz[1] = sqrt$3(xyz[1]); - xyz[2] = sqrt$3(xyz[2]); - if (xyz[3] > 0.9999999) { - xyz[3] = 1; - } - return new Color_1(clip_rgb$2(xyz)); - }; - var type$j = utils.type; - var pow$5 = Math.pow; - var scale = function(colors) { - var _mode = "rgb"; - var _nacol = chroma_1("#ccc"); - var _spread = 0; - var _domain = [0, 1]; - var _pos = []; - var _padding = [0, 0]; - var _classes = false; - var _colors = []; - var _out = false; - var _min = 0; - var _max = 1; - var _correctLightness = false; - var _colorCache = {}; - var _useCache = true; - var _gamma = 1; - var setColors = function(colors2) { - colors2 = colors2 || ["#fff", "#000"]; - if (colors2 && type$j(colors2) === "string" && chroma_1.brewer && chroma_1.brewer[colors2.toLowerCase()]) { - colors2 = chroma_1.brewer[colors2.toLowerCase()]; - } - if (type$j(colors2) === "array") { - if (colors2.length === 1) { - colors2 = [colors2[0], colors2[0]]; - } - colors2 = colors2.slice(0); - for (var c = 0; c < colors2.length; c++) { - colors2[c] = chroma_1(colors2[c]); - } - _pos.length = 0; - for (var c$1 = 0; c$1 < colors2.length; c$1++) { - _pos.push(c$1 / (colors2.length - 1)); - } - } - resetCache(); - return _colors = colors2; - }; - var getClass = function(value) { - if (_classes != null) { - var n = _classes.length - 1; - var i2 = 0; - while (i2 < n && value >= _classes[i2]) { - i2++; - } - return i2 - 1; - } - return 0; - }; - var tMapLightness = function(t) { - return t; - }; - var tMapDomain = function(t) { - return t; - }; - var getColor = function(val, bypassMap) { - var col, t; - if (bypassMap == null) { - bypassMap = false; - } - if (isNaN(val) || val === null) { - return _nacol; - } - if (!bypassMap) { - if (_classes && _classes.length > 2) { - var c = getClass(val); - t = c / (_classes.length - 2); - } else if (_max !== _min) { - t = (val - _min) / (_max - _min); - } else { - t = 1; - } - } else { - t = val; - } - t = tMapDomain(t); - if (!bypassMap) { - t = tMapLightness(t); - } - if (_gamma !== 1) { - t = pow$5(t, _gamma); - } - t = _padding[0] + t * (1 - _padding[0] - _padding[1]); - t = Math.min(1, Math.max(0, t)); - var k = Math.floor(t * 1e4); - if (_useCache && _colorCache[k]) { - col = _colorCache[k]; - } else { - if (type$j(_colors) === "array") { - for (var i2 = 0; i2 < _pos.length; i2++) { - var p = _pos[i2]; - if (t <= p) { - col = _colors[i2]; - break; - } - if (t >= p && i2 === _pos.length - 1) { - col = _colors[i2]; - break; - } - if (t > p && t < _pos[i2 + 1]) { - t = (t - p) / (_pos[i2 + 1] - p); - col = chroma_1.interpolate(_colors[i2], _colors[i2 + 1], t, _mode); - break; - } - } - } else if (type$j(_colors) === "function") { - col = _colors(t); - } - if (_useCache) { - _colorCache[k] = col; - } - } - return col; - }; - var resetCache = function() { - return _colorCache = {}; - }; - setColors(colors); - var f = function(v) { - var c = chroma_1(getColor(v)); - if (_out && c[_out]) { - return c[_out](); - } else { - return c; - } - }; - f.classes = function(classes) { - if (classes != null) { - if (type$j(classes) === "array") { - _classes = classes; - _domain = [classes[0], classes[classes.length - 1]]; - } else { - var d = chroma_1.analyze(_domain); - if (classes === 0) { - _classes = [d.min, d.max]; - } else { - _classes = chroma_1.limits(d, "e", classes); - } - } - return f; - } - return _classes; - }; - f.domain = function(domain) { - if (!arguments.length) { - return _domain; - } - _min = domain[0]; - _max = domain[domain.length - 1]; - _pos = []; - var k = _colors.length; - if (domain.length === k && _min !== _max) { - for (var i2 = 0, list2 = Array.from(domain); i2 < list2.length; i2 += 1) { - var d = list2[i2]; - _pos.push((d - _min) / (_max - _min)); - } - } else { - for (var c = 0; c < k; c++) { - _pos.push(c / (k - 1)); - } - if (domain.length > 2) { - var tOut = domain.map(function(d2, i3) { - return i3 / (domain.length - 1); - }); - var tBreaks = domain.map(function(d2) { - return (d2 - _min) / (_max - _min); - }); - if (!tBreaks.every(function(val, i3) { - return tOut[i3] === val; - })) { - tMapDomain = function(t) { - if (t <= 0 || t >= 1) { - return t; - } - var i3 = 0; - while (t >= tBreaks[i3 + 1]) { - i3++; - } - var f2 = (t - tBreaks[i3]) / (tBreaks[i3 + 1] - tBreaks[i3]); - var out = tOut[i3] + f2 * (tOut[i3 + 1] - tOut[i3]); - return out; - }; - } - } - } - _domain = [_min, _max]; - return f; - }; - f.mode = function(_m) { - if (!arguments.length) { - return _mode; - } - _mode = _m; - resetCache(); - return f; - }; - f.range = function(colors2, _pos2) { - setColors(colors2, _pos2); - return f; - }; - f.out = function(_o) { - _out = _o; - return f; - }; - f.spread = function(val) { - if (!arguments.length) { - return _spread; - } - _spread = val; - return f; - }; - f.correctLightness = function(v) { - if (v == null) { - v = true; - } - _correctLightness = v; - resetCache(); - if (_correctLightness) { - tMapLightness = function(t) { - var L0 = getColor(0, true).lab()[0]; - var L1 = getColor(1, true).lab()[0]; - var pol = L0 > L1; - var L_actual = getColor(t, true).lab()[0]; - var L_ideal = L0 + (L1 - L0) * t; - var L_diff = L_actual - L_ideal; - var t0 = 0; - var t1 = 1; - var max_iter = 20; - while (Math.abs(L_diff) > 0.01 && max_iter-- > 0) { - (function() { - if (pol) { - L_diff *= -1; - } - if (L_diff < 0) { - t0 = t; - t += (t1 - t) * 0.5; - } else { - t1 = t; - t += (t0 - t) * 0.5; - } - L_actual = getColor(t, true).lab()[0]; - return L_diff = L_actual - L_ideal; - })(); - } - return t; - }; - } else { - tMapLightness = function(t) { - return t; - }; - } - return f; - }; - f.padding = function(p) { - if (p != null) { - if (type$j(p) === "number") { - p = [p, p]; - } - _padding = p; - return f; - } else { - return _padding; - } - }; - f.colors = function(numColors, out) { - if (arguments.length < 2) { - out = "hex"; - } - var result = []; - if (arguments.length === 0) { - result = _colors.slice(0); - } else if (numColors === 1) { - result = [f(0.5)]; - } else if (numColors > 1) { - var dm = _domain[0]; - var dd = _domain[1] - dm; - result = __range__(0, numColors, false).map(function(i3) { - return f(dm + i3 / (numColors - 1) * dd); - }); - } else { - colors = []; - var samples = []; - if (_classes && _classes.length > 2) { - for (var i2 = 1, end = _classes.length, asc = 1 <= end; asc ? i2 < end : i2 > end; asc ? i2++ : i2--) { - samples.push((_classes[i2 - 1] + _classes[i2]) * 0.5); - } - } else { - samples = _domain; - } - result = samples.map(function(v) { - return f(v); - }); - } - if (chroma_1[out]) { - result = result.map(function(c) { - return c[out](); - }); - } - return result; - }; - f.cache = function(c) { - if (c != null) { - _useCache = c; - return f; - } else { - return _useCache; - } - }; - f.gamma = function(g) { - if (g != null) { - _gamma = g; - return f; - } else { - return _gamma; - } - }; - f.nodata = function(d) { - if (d != null) { - _nacol = chroma_1(d); - return f; - } else { - return _nacol; - } - }; - return f; - }; - function __range__(left, right, inclusive) { - var range = []; - var ascending = left < right; - var end = !inclusive ? right : ascending ? right + 1 : right - 1; - for (var i2 = left; ascending ? i2 < end : i2 > end; ascending ? i2++ : i2--) { - range.push(i2); - } - return range; - } - var bezier = function(colors) { - var assign, assign$1, assign$2; - var I, lab0, lab1, lab2; - colors = colors.map(function(c) { - return new Color_1(c); - }); - if (colors.length === 2) { - assign = colors.map(function(c) { - return c.lab(); - }), lab0 = assign[0], lab1 = assign[1]; - I = function(t) { - var lab = [0, 1, 2].map(function(i2) { - return lab0[i2] + t * (lab1[i2] - lab0[i2]); - }); - return new Color_1(lab, "lab"); - }; - } else if (colors.length === 3) { - assign$1 = colors.map(function(c) { - return c.lab(); - }), lab0 = assign$1[0], lab1 = assign$1[1], lab2 = assign$1[2]; - I = function(t) { - var lab = [0, 1, 2].map(function(i2) { - return (1 - t) * (1 - t) * lab0[i2] + 2 * (1 - t) * t * lab1[i2] + t * t * lab2[i2]; - }); - return new Color_1(lab, "lab"); - }; - } else if (colors.length === 4) { - var lab3; - assign$2 = colors.map(function(c) { - return c.lab(); - }), lab0 = assign$2[0], lab1 = assign$2[1], lab2 = assign$2[2], lab3 = assign$2[3]; - I = function(t) { - var lab = [0, 1, 2].map(function(i2) { - return (1 - t) * (1 - t) * (1 - t) * lab0[i2] + 3 * (1 - t) * (1 - t) * t * lab1[i2] + 3 * (1 - t) * t * t * lab2[i2] + t * t * t * lab3[i2]; - }); - return new Color_1(lab, "lab"); - }; - } else if (colors.length === 5) { - var I0 = bezier(colors.slice(0, 3)); - var I1 = bezier(colors.slice(2, 5)); - I = function(t) { - if (t < 0.5) { - return I0(t * 2); - } else { - return I1((t - 0.5) * 2); - } - }; - } - return I; - }; - var bezier_1 = function(colors) { - var f = bezier(colors); - f.scale = function() { - return scale(f); - }; - return f; - }; - var blend = function(bottom, top, mode) { - if (!blend[mode]) { - throw new Error("unknown blend mode " + mode); - } - return blend[mode](bottom, top); - }; - var blend_f = function(f) { - return function(bottom, top) { - var c0 = chroma_1(top).rgb(); - var c1 = chroma_1(bottom).rgb(); - return chroma_1.rgb(f(c0, c1)); - }; - }; - var each = function(f) { - return function(c0, c1) { - var out = []; - out[0] = f(c0[0], c1[0]); - out[1] = f(c0[1], c1[1]); - out[2] = f(c0[2], c1[2]); - return out; - }; - }; - var normal = function(a) { - return a; - }; - var multiply = function(a, b) { - return a * b / 255; - }; - var darken$1 = function(a, b) { - return a > b ? b : a; - }; - var lighten = function(a, b) { - return a > b ? a : b; - }; - var screen = function(a, b) { - return 255 * (1 - (1 - a / 255) * (1 - b / 255)); - }; - var overlay = function(a, b) { - return b < 128 ? 2 * a * b / 255 : 255 * (1 - 2 * (1 - a / 255) * (1 - b / 255)); - }; - var burn = function(a, b) { - return 255 * (1 - (1 - b / 255) / (a / 255)); - }; - var dodge = function(a, b) { - if (a === 255) { - return 255; - } - a = 255 * (b / 255) / (1 - a / 255); - return a > 255 ? 255 : a; - }; - blend.normal = blend_f(each(normal)); - blend.multiply = blend_f(each(multiply)); - blend.screen = blend_f(each(screen)); - blend.overlay = blend_f(each(overlay)); - blend.darken = blend_f(each(darken$1)); - blend.lighten = blend_f(each(lighten)); - blend.dodge = blend_f(each(dodge)); - blend.burn = blend_f(each(burn)); - var blend_1 = blend; - var type$k = utils.type; - var clip_rgb$3 = utils.clip_rgb; - var TWOPI$2 = utils.TWOPI; - var pow$6 = Math.pow; - var sin$2 = Math.sin; - var cos$3 = Math.cos; - var cubehelix = function(start, rotations, hue, gamma, lightness) { - if (start === void 0) - start = 300; - if (rotations === void 0) - rotations = -1.5; - if (hue === void 0) - hue = 1; - if (gamma === void 0) - gamma = 1; - if (lightness === void 0) - lightness = [0, 1]; - var dh = 0, dl; - if (type$k(lightness) === "array") { - dl = lightness[1] - lightness[0]; - } else { - dl = 0; - lightness = [lightness, lightness]; - } - var f = function(fract) { - var a = TWOPI$2 * ((start + 120) / 360 + rotations * fract); - var l = pow$6(lightness[0] + dl * fract, gamma); - var h = dh !== 0 ? hue[0] + fract * dh : hue; - var amp = h * l * (1 - l) / 2; - var cos_a = cos$3(a); - var sin_a = sin$2(a); - var r = l + amp * (-0.14861 * cos_a + 1.78277 * sin_a); - var g = l + amp * (-0.29227 * cos_a - 0.90649 * sin_a); - var b = l + amp * (1.97294 * cos_a); - return chroma_1(clip_rgb$3([r * 255, g * 255, b * 255, 1])); - }; - f.start = function(s) { - if (s == null) { - return start; - } - start = s; - return f; - }; - f.rotations = function(r) { - if (r == null) { - return rotations; - } - rotations = r; - return f; - }; - f.gamma = function(g) { - if (g == null) { - return gamma; - } - gamma = g; - return f; - }; - f.hue = function(h) { - if (h == null) { - return hue; - } - hue = h; - if (type$k(hue) === "array") { - dh = hue[1] - hue[0]; - if (dh === 0) { - hue = hue[1]; - } - } else { - dh = 0; - } - return f; - }; - f.lightness = function(h) { - if (h == null) { - return lightness; - } - if (type$k(h) === "array") { - lightness = h; - dl = h[1] - h[0]; - } else { - lightness = [h, h]; - dl = 0; - } - return f; - }; - f.scale = function() { - return chroma_1.scale(f); - }; - f.hue(hue); - return f; - }; - var digits = "0123456789abcdef"; - var floor$2 = Math.floor; - var random = Math.random; - var random_1 = function() { - var code = "#"; - for (var i2 = 0; i2 < 6; i2++) { - code += digits.charAt(floor$2(random() * 16)); - } - return new Color_1(code, "hex"); - }; - var log$1 = Math.log; - var pow$7 = Math.pow; - var floor$3 = Math.floor; - var abs = Math.abs; - var analyze = function(data, key2) { - if (key2 === void 0) - key2 = null; - var r = { - min: Number.MAX_VALUE, - max: Number.MAX_VALUE * -1, - sum: 0, - values: [], - count: 0 - }; - if (type(data) === "object") { - data = Object.values(data); - } - data.forEach(function(val) { - if (key2 && type(val) === "object") { - val = val[key2]; - } - if (val !== void 0 && val !== null && !isNaN(val)) { - r.values.push(val); - r.sum += val; - if (val < r.min) { - r.min = val; - } - if (val > r.max) { - r.max = val; - } - r.count += 1; - } - }); - r.domain = [r.min, r.max]; - r.limits = function(mode, num) { - return limits(r, mode, num); - }; - return r; - }; - var limits = function(data, mode, num) { - if (mode === void 0) - mode = "equal"; - if (num === void 0) - num = 7; - if (type(data) == "array") { - data = analyze(data); - } - var min2 = data.min; - var max2 = data.max; - var values = data.values.sort(function(a, b) { - return a - b; - }); - if (num === 1) { - return [min2, max2]; - } - var limits2 = []; - if (mode.substr(0, 1) === "c") { - limits2.push(min2); - limits2.push(max2); - } - if (mode.substr(0, 1) === "e") { - limits2.push(min2); - for (var i2 = 1; i2 < num; i2++) { - limits2.push(min2 + i2 / num * (max2 - min2)); - } - limits2.push(max2); - } else if (mode.substr(0, 1) === "l") { - if (min2 <= 0) { - throw new Error("Logarithmic scales are only possible for values > 0"); - } - var min_log = Math.LOG10E * log$1(min2); - var max_log = Math.LOG10E * log$1(max2); - limits2.push(min2); - for (var i$12 = 1; i$12 < num; i$12++) { - limits2.push(pow$7(10, min_log + i$12 / num * (max_log - min_log))); - } - limits2.push(max2); - } else if (mode.substr(0, 1) === "q") { - limits2.push(min2); - for (var i$2 = 1; i$2 < num; i$2++) { - var p = (values.length - 1) * i$2 / num; - var pb = floor$3(p); - if (pb === p) { - limits2.push(values[pb]); - } else { - var pr = p - pb; - limits2.push(values[pb] * (1 - pr) + values[pb + 1] * pr); - } - } - limits2.push(max2); - } else if (mode.substr(0, 1) === "k") { - var cluster; - var n = values.length; - var assignments = new Array(n); - var clusterSizes = new Array(num); - var repeat = true; - var nb_iters = 0; - var centroids = null; - centroids = []; - centroids.push(min2); - for (var i$3 = 1; i$3 < num; i$3++) { - centroids.push(min2 + i$3 / num * (max2 - min2)); - } - centroids.push(max2); - while (repeat) { - for (var j = 0; j < num; j++) { - clusterSizes[j] = 0; - } - for (var i$4 = 0; i$4 < n; i$4++) { - var value = values[i$4]; - var mindist = Number.MAX_VALUE; - var best = void 0; - for (var j$1 = 0; j$1 < num; j$1++) { - var dist = abs(centroids[j$1] - value); - if (dist < mindist) { - mindist = dist; - best = j$1; - } - clusterSizes[best]++; - assignments[i$4] = best; - } - } - var newCentroids = new Array(num); - for (var j$2 = 0; j$2 < num; j$2++) { - newCentroids[j$2] = null; - } - for (var i$5 = 0; i$5 < n; i$5++) { - cluster = assignments[i$5]; - if (newCentroids[cluster] === null) { - newCentroids[cluster] = values[i$5]; - } else { - newCentroids[cluster] += values[i$5]; - } - } - for (var j$3 = 0; j$3 < num; j$3++) { - newCentroids[j$3] *= 1 / clusterSizes[j$3]; - } - repeat = false; - for (var j$4 = 0; j$4 < num; j$4++) { - if (newCentroids[j$4] !== centroids[j$4]) { - repeat = true; - break; - } - } - centroids = newCentroids; - nb_iters++; - if (nb_iters > 200) { - repeat = false; - } - } - var kClusters = {}; - for (var j$5 = 0; j$5 < num; j$5++) { - kClusters[j$5] = []; - } - for (var i$6 = 0; i$6 < n; i$6++) { - cluster = assignments[i$6]; - kClusters[cluster].push(values[i$6]); - } - var tmpKMeansBreaks = []; - for (var j$6 = 0; j$6 < num; j$6++) { - tmpKMeansBreaks.push(kClusters[j$6][0]); - tmpKMeansBreaks.push(kClusters[j$6][kClusters[j$6].length - 1]); - } - tmpKMeansBreaks = tmpKMeansBreaks.sort(function(a, b) { - return a - b; - }); - limits2.push(tmpKMeansBreaks[0]); - for (var i$7 = 1; i$7 < tmpKMeansBreaks.length; i$7 += 2) { - var v = tmpKMeansBreaks[i$7]; - if (!isNaN(v) && limits2.indexOf(v) === -1) { - limits2.push(v); - } - } - } - return limits2; - }; - var analyze_1 = { analyze, limits }; - var contrast = function(a, b) { - a = new Color_1(a); - b = new Color_1(b); - var l1 = a.luminance(); - var l2 = b.luminance(); - return l1 > l2 ? (l1 + 0.05) / (l2 + 0.05) : (l2 + 0.05) / (l1 + 0.05); - }; - var sqrt$4 = Math.sqrt; - var atan2$2 = Math.atan2; - var abs$1 = Math.abs; - var cos$4 = Math.cos; - var PI$2 = Math.PI; - var deltaE = function(a, b, L, C) { - if (L === void 0) - L = 1; - if (C === void 0) - C = 1; - a = new Color_1(a); - b = new Color_1(b); - var ref = Array.from(a.lab()); - var L1 = ref[0]; - var a1 = ref[1]; - var b1 = ref[2]; - var ref$1 = Array.from(b.lab()); - var L2 = ref$1[0]; - var a2 = ref$1[1]; - var b2 = ref$1[2]; - var c1 = sqrt$4(a1 * a1 + b1 * b1); - var c2 = sqrt$4(a2 * a2 + b2 * b2); - var sl = L1 < 16 ? 0.511 : 0.040975 * L1 / (1 + 0.01765 * L1); - var sc = 0.0638 * c1 / (1 + 0.0131 * c1) + 0.638; - var h1 = c1 < 1e-6 ? 0 : atan2$2(b1, a1) * 180 / PI$2; - while (h1 < 0) { - h1 += 360; - } - while (h1 >= 360) { - h1 -= 360; - } - var t = h1 >= 164 && h1 <= 345 ? 0.56 + abs$1(0.2 * cos$4(PI$2 * (h1 + 168) / 180)) : 0.36 + abs$1(0.4 * cos$4(PI$2 * (h1 + 35) / 180)); - var c4 = c1 * c1 * c1 * c1; - var f = sqrt$4(c4 / (c4 + 1900)); - var sh = sc * (f * t + 1 - f); - var delL = L1 - L2; - var delC = c1 - c2; - var delA = a1 - a2; - var delB = b1 - b2; - var dH2 = delA * delA + delB * delB - delC * delC; - var v1 = delL / (L * sl); - var v2 = delC / (C * sc); - var v3 = sh; - return sqrt$4(v1 * v1 + v2 * v2 + dH2 / (v3 * v3)); - }; - var distance = function(a, b, mode) { - if (mode === void 0) - mode = "lab"; - a = new Color_1(a); - b = new Color_1(b); - var l1 = a.get(mode); - var l2 = b.get(mode); - var sum_sq = 0; - for (var i2 in l1) { - var d = (l1[i2] || 0) - (l2[i2] || 0); - sum_sq += d * d; - } - return Math.sqrt(sum_sq); - }; - var valid = function() { - var args = [], len = arguments.length; - while (len--) - args[len] = arguments[len]; - try { - new (Function.prototype.bind.apply(Color_1, [null].concat(args)))(); - return true; - } catch (e) { - return false; - } - }; - var scales = { - cool: function cool() { - return scale([chroma_1.hsl(180, 1, 0.9), chroma_1.hsl(250, 0.7, 0.4)]); - }, - hot: function hot() { - return scale(["#000", "#f00", "#ff0", "#fff"], [0, 0.25, 0.75, 1]).mode("rgb"); - } - }; - var colorbrewer = { - OrRd: ["#fff7ec", "#fee8c8", "#fdd49e", "#fdbb84", "#fc8d59", "#ef6548", "#d7301f", "#b30000", "#7f0000"], - PuBu: ["#fff7fb", "#ece7f2", "#d0d1e6", "#a6bddb", "#74a9cf", "#3690c0", "#0570b0", "#045a8d", "#023858"], - BuPu: ["#f7fcfd", "#e0ecf4", "#bfd3e6", "#9ebcda", "#8c96c6", "#8c6bb1", "#88419d", "#810f7c", "#4d004b"], - Oranges: ["#fff5eb", "#fee6ce", "#fdd0a2", "#fdae6b", "#fd8d3c", "#f16913", "#d94801", "#a63603", "#7f2704"], - BuGn: ["#f7fcfd", "#e5f5f9", "#ccece6", "#99d8c9", "#66c2a4", "#41ae76", "#238b45", "#006d2c", "#00441b"], - YlOrBr: ["#ffffe5", "#fff7bc", "#fee391", "#fec44f", "#fe9929", "#ec7014", "#cc4c02", "#993404", "#662506"], - YlGn: ["#ffffe5", "#f7fcb9", "#d9f0a3", "#addd8e", "#78c679", "#41ab5d", "#238443", "#006837", "#004529"], - Reds: ["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d"], - RdPu: ["#fff7f3", "#fde0dd", "#fcc5c0", "#fa9fb5", "#f768a1", "#dd3497", "#ae017e", "#7a0177", "#49006a"], - Greens: ["#f7fcf5", "#e5f5e0", "#c7e9c0", "#a1d99b", "#74c476", "#41ab5d", "#238b45", "#006d2c", "#00441b"], - YlGnBu: ["#ffffd9", "#edf8b1", "#c7e9b4", "#7fcdbb", "#41b6c4", "#1d91c0", "#225ea8", "#253494", "#081d58"], - Purples: ["#fcfbfd", "#efedf5", "#dadaeb", "#bcbddc", "#9e9ac8", "#807dba", "#6a51a3", "#54278f", "#3f007d"], - GnBu: ["#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081"], - Greys: ["#ffffff", "#f0f0f0", "#d9d9d9", "#bdbdbd", "#969696", "#737373", "#525252", "#252525", "#000000"], - YlOrRd: ["#ffffcc", "#ffeda0", "#fed976", "#feb24c", "#fd8d3c", "#fc4e2a", "#e31a1c", "#bd0026", "#800026"], - PuRd: ["#f7f4f9", "#e7e1ef", "#d4b9da", "#c994c7", "#df65b0", "#e7298a", "#ce1256", "#980043", "#67001f"], - Blues: ["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"], - PuBuGn: ["#fff7fb", "#ece2f0", "#d0d1e6", "#a6bddb", "#67a9cf", "#3690c0", "#02818a", "#016c59", "#014636"], - Viridis: ["#440154", "#482777", "#3f4a8a", "#31678e", "#26838f", "#1f9d8a", "#6cce5a", "#b6de2b", "#fee825"], - Spectral: ["#9e0142", "#d53e4f", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#e6f598", "#abdda4", "#66c2a5", "#3288bd", "#5e4fa2"], - RdYlGn: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#d9ef8b", "#a6d96a", "#66bd63", "#1a9850", "#006837"], - RdBu: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#f7f7f7", "#d1e5f0", "#92c5de", "#4393c3", "#2166ac", "#053061"], - PiYG: ["#8e0152", "#c51b7d", "#de77ae", "#f1b6da", "#fde0ef", "#f7f7f7", "#e6f5d0", "#b8e186", "#7fbc41", "#4d9221", "#276419"], - PRGn: ["#40004b", "#762a83", "#9970ab", "#c2a5cf", "#e7d4e8", "#f7f7f7", "#d9f0d3", "#a6dba0", "#5aae61", "#1b7837", "#00441b"], - RdYlBu: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee090", "#ffffbf", "#e0f3f8", "#abd9e9", "#74add1", "#4575b4", "#313695"], - BrBG: ["#543005", "#8c510a", "#bf812d", "#dfc27d", "#f6e8c3", "#f5f5f5", "#c7eae5", "#80cdc1", "#35978f", "#01665e", "#003c30"], - RdGy: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#ffffff", "#e0e0e0", "#bababa", "#878787", "#4d4d4d", "#1a1a1a"], - PuOr: ["#7f3b08", "#b35806", "#e08214", "#fdb863", "#fee0b6", "#f7f7f7", "#d8daeb", "#b2abd2", "#8073ac", "#542788", "#2d004b"], - Set2: ["#66c2a5", "#fc8d62", "#8da0cb", "#e78ac3", "#a6d854", "#ffd92f", "#e5c494", "#b3b3b3"], - Accent: ["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0", "#f0027f", "#bf5b17", "#666666"], - Set1: ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999"], - Set3: ["#8dd3c7", "#ffffb3", "#bebada", "#fb8072", "#80b1d3", "#fdb462", "#b3de69", "#fccde5", "#d9d9d9", "#bc80bd", "#ccebc5", "#ffed6f"], - Dark2: ["#1b9e77", "#d95f02", "#7570b3", "#e7298a", "#66a61e", "#e6ab02", "#a6761d", "#666666"], - Paired: ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c", "#fb9a99", "#e31a1c", "#fdbf6f", "#ff7f00", "#cab2d6", "#6a3d9a", "#ffff99", "#b15928"], - Pastel2: ["#b3e2cd", "#fdcdac", "#cbd5e8", "#f4cae4", "#e6f5c9", "#fff2ae", "#f1e2cc", "#cccccc"], - Pastel1: ["#fbb4ae", "#b3cde3", "#ccebc5", "#decbe4", "#fed9a6", "#ffffcc", "#e5d8bd", "#fddaec", "#f2f2f2"] - }; - for (var i$1 = 0, list$1 = Object.keys(colorbrewer); i$1 < list$1.length; i$1 += 1) { - var key = list$1[i$1]; - colorbrewer[key.toLowerCase()] = colorbrewer[key]; - } - var colorbrewer_1 = colorbrewer; - chroma_1.average = average; - chroma_1.bezier = bezier_1; - chroma_1.blend = blend_1; - chroma_1.cubehelix = cubehelix; - chroma_1.mix = chroma_1.interpolate = mix; - chroma_1.random = random_1; - chroma_1.scale = scale; - chroma_1.analyze = analyze_1.analyze; - chroma_1.contrast = contrast; - chroma_1.deltaE = deltaE; - chroma_1.distance = distance; - chroma_1.limits = analyze_1.limits; - chroma_1.valid = valid; - chroma_1.scales = scales; - chroma_1.colors = w3cx11_1; - chroma_1.brewer = colorbrewer_1; - var chroma_js = chroma_1; - return chroma_js; - }); - } - }); - - // src/index.js - var src_exports = {}; - __export(src_exports, { - default: () => src_default - }); - var import_chroma_js = __toModule(require_chroma()); - - // src/en.js - var en_default = { - "descriptions": [ - { - "criteria": { - "hsl": [ - null, - [ - 0.75, - 1 - ], - [ - 0.4, - 0.55 - ] - ] - }, - "descriptive": [ - "saturated", - "strong", - "lush", - "ablaze", - "beaming", - "bold", - "brilliant", - "flamboyant", - "vibrant", - "vivid", - "loud" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0, - 0.07 - ] - ] - }, - "descriptive": [ - "dark", - "ashy", - "somber", - "bleak", - "muddy", - "sooty" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0, - 0.3 - ] - ] - }, - "descriptive": [ - "dark", - "dim", - "gloomy", - "dull" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.1, - 0.7 - ], - [ - 0.15, - 0.5 - ] - ] - }, - "descriptive": [ - "bleak", - "muted", - "matte", - "dusty" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.12, - 1 - ], - [ - 0.7, - 1 - ] - ] - }, - "descriptive": [ - "tinted" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.2, - 1 - ], - [ - 0.75, - 0.95 - ] - ] - }, - "descriptive": [ - "pastel" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0.88, - 1 - ] - ] - }, - "descriptive": [ - "pale", - "light", - "faded", - "delicate", - "glistening", - "bleached" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.5, - 1 - ], - [ - 0.7, - 0.9 - ] - ] - }, - "descriptive": [ - "fresh", - "sparkling", - "glittering", - "glowing", - "jazzy", - "opalescent" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0.9, - 1 - ] - ] - }, - "descriptive": [ - "neutral" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.74, - 1 - ], - [ - 0.9, - 1 - ] - ] - }, - "descriptive": [ - "muted" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - 1 - ] - }, - "descriptive": [ - "colorless", - "bright", - "brilliant", - "high" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - 0 - ] - }, - "descriptive": [ - "colorless", - "low", - "dark" - ] - }, - { - "criteria": { - "hsl": [ - null, - [0, 0.01], - null - ] - }, - "descriptive": [ - "colorless", - "neutral" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0.01, - 0.3 - ] - ] - }, - "descriptive": [ - "shady" - ] - }, - { - "criteria": { - "hsl": [ - null, - [0, 0.4], - null - ] - }, - "descriptive": [ - "ashy", - "dusty" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0.01, - 0.08 - ] - ] - }, - "descriptive": [ - "almost black" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0, - 0.02 - ] - ] - }, - "descriptive": [ - "black" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0, - 0.09 - ] - ] - }, - "descriptive": [ - "very dark" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0, - 0.4 - ], - [ - 0, - 0.22 - ] - ] - }, - "descriptive": [ - "dark" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.1, - 0.4 - ], - [ - 0, - 0.6 - ] - ] - }, - "descriptive": [ - "dark", - "inky", - "dim", - "gloomy" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0, - 0.04 - ], - [ - 0.1, - 0.99 - ] - ] - }, - "descriptive": [ - "grey" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.04, - 0.1 - ], - [ - 0.17, - 0.99 - ] - ] - }, - "descriptive": [ - "almost grey" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.1, - 0.3 - ], - [ - 0.17, - 0.99 - ] - ] - }, - "descriptive": [ - "very unsaturated" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.3, - 0.46 - ], - null - ] - }, - "descriptive": [ - "unsaturated" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.46, - 0.6 - ], - [ - 0.4, - 0.55 - ] - ] - }, - "descriptive": [ - "rather unsaturated" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.601, - 0.8 - ], - [ - 0.45, - 0.6 - ] - ] - }, - "descriptive": [ - "saturated" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.801, - 0.94 - ], - [ - 0.45, - 0.6 - ] - ] - }, - "descriptive": [ - "rather saturated" - ] - }, - { - "criteria": { - "hsl": [ - null, - [ - 0.941, - 1 - ], - [ - 0.45, - 0.6 - ] - ] - }, - "descriptive": [ - "very saturated" - ] - }, - { - "criteria": { - "hsl": [ - [ - 0, - 90 - ], - [ - 0.3, - 1 - ], - [ - 0.1, - 1 - ] - ] - }, - "descriptive": [ - "warm", - "mellow" - ] - }, - { - "criteria": { - "hsl": [ - [ - 270, - 360 - ], - [ - 0.3, - 1 - ], - [ - 0.1, - 1 - ] - ] - }, - "descriptive": [ - "warm", - "mellow" - ] - }, - { - "criteria": { - "hsl": [ - [ - 90.01, - 269.99 - ], - null, - [ - 0.1, - 1 - ] - ] - }, - "descriptive": [ - "cold", - "cool" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0.98, - 1 - ] - ] - }, - "nouns": [ - "white" - ], - "description": [ - "White is a color that is often associated with purity, innocence, and cleanliness. It is the lightest color on the visible spectrum and is often described as having a bright, luminous quality. When you think of white, you might imagine a freshly fallen snow, a blank canvas, or a cloudless sky. It is a versatile color that can be used in a wide range of settings and contexts, from formal to casual. If you close your eyes and picture white, you might imagine a bright, radiant light that illuminates everything around it." - ], - "meanings": [ - "purity", - "cleanliness", - "simplicity", - "innocence", - "freshness", - "light", - "goodness", - "virtue", - "safety", - "peace", - "tranquility", - "wholeness", - "perfection", - "honesty", - "truth", - "sincerity" - ], - "usage": [ - "health", - "hospital", - "sanitary" - ] - }, - { - "criteria": { - "hsl": [ - null, - null, - [ - 0, - 0.08 - ] - ] - }, - "nouns": [ - "black" - ], - "description": [ - "Black is a color that is often associated with power, elegance, and sophistication. It is a color that is often used to create a sense of mystery, depth, and contrast, and it is often described as a color that can be both bold and elegant. In art and design, black is often used to create a sense of sophistication and drama, and it is often used in fashion to create a sense of sophistication and refinement." - ], - "meanings": [ - "power", - "control", - "authority", - "discipline", - "discretion", - "secrecy", - "elegance", - "mystery" - ], - "usage": [ - "intimidate", - "create fear", - "authority", - "luxury" - ] - }, - { - "criteria": { - "hsl": [ - [ - 0, - 15 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "red", - "reddish" - ], - "nouns": [ - "red" - ], - "description": [ - "Red is a warm, vibrant color that is often associated with passion and excitement. It is the color of fire, and it is often used to grab attention and convey a sense of urgency or danger. In terms of wavelength, red is the color that is associated with the longest wavelengths of visible light, and it is one of the primary colors of light, along with blue and green. Some people may associate the color red with feelings of love and warmth, while others may associate it with anger or danger. Overall, red is a bold and striking color that can be used to convey a wide range of emotions and messages." - ], - "meanings": [ - "excitement", - "energy", - "passion", - "courage", - "attention", - "lust", - "power", - "love", - "speed", - "anger", - "lust", - "excitement", - "danger", - "ferocity", - "violence", - "fury", - "anger", - "vigor", - "urgency" - ], - "usage": [ - "stimulate", - "create urgency", - "draw attention", - "caution", - "encourage", - "excite" - ] - }, - { - "criteria": { - "hsl": [ - [ - 15, - 45 - ], - [ - 0.1, - 1 - ], - [ - 0.4, - 0.99 - ] - ] - }, - "descriptive": [ - "orange" - ], - "nouns": [ - "orange" - ], - "description": [ - "Orange is a vibrant and playful color that is often associated with creativity, energy, and warmth. It is a secondary color that is made by combining red and yellow, and it is often described as a warm and friendly color that can be both invigorating and calming. It is often associated with joy, enthusiasm, and warmth, and it is often used in art and design to create a sense of excitement and playfulness." - ], - "meanings": [ - "optimism", - "independence", - "adventure", - "creativity", - "fun" - ], - "usage": [ - "stimulate", - "draw attention", - "express freedom", - "fascinate" - ] - }, - { - "criteria": { - "hsl": [ - [ - 15, - 45 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.4 - ] - ] - }, - "descriptive": [ - "brown" - ], - "nouns": [ - "brown" - ], - "description": ["Brown is a warm and earthy color that is often associated with nature, stability, and reliability. It is a secondary color that is made by combining red, blue, and yellow in different proportions, and it is often described as a rich and luxurious color that can be both comforting and grounding. It is often associated with wood, soil, and the natural world, and it is often used in art and design to create a sense of warmth and permanence."], - "meanings": [ - "strength", - "reliability", - "resilience", - "loneliness", - "sadness", - "isolation", - "warmth", - "comfort", - "security" - ], - "usage": [ - "agriculture", - "legal", - "food", - "tobacco", - "alcohol" - ] - }, - { - "criteria": { - "hsl": [ - [ - 45, - 70 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "yellow" - ], - "nouns": [ - "yellow" - ], - "description": ["Yellow is a bright and cheerful color that is often associated with sunshine, happiness, and warmth. It is a primary color that is made by combining red and green light, and it is usually described as a warm and vibrant color that can be both calming and energizing. It is often associated with joy, happiness, and friendship, and it is often used in art and design to create a sense of cheerfulness and playfulness."], - "meanings": [ - "enthusiasm", - "opportunity", - "spontaneity", - "happiness", - "positivity" - ], - "usage": [ - "stimulate", - "relax", - "awake awareness", - "energize", - "affect mood", - "sale", - "cheap", - "budget", - "construction", - "convey competence" - ] - }, - { - "criteria": { - "hsl": [ - [ - 70, - 79 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "lime" - ], - "nouns": [ - "lime" - ], - "description": ["Lime is a bright, vibrant color that is often associated with freshness, energy, and youth. It is a pale shade of green that is similar to chartreuse, but it is slightly lighter and more vibrant. Some people may associate the color lime with feelings of playfulness and excitement, while others may associate it with feelings of rejuvenation and renewal. In terms of wavelength, lime is a mixture of green and yellow light, and it is often used in art and design to create a sense of energy and vitality. Overall, lime is a lively and refreshing color that can be used to create a wide range of moods and atmospheres."], - "meanings": [ - "growth", - "harmony", - "fertility", - "kindness", - "dependability" - ], - "usage": [ - "restore energy", - "promote growth", - "awake awareness", - "rejuvenate", - "nature" - ] - }, - { - "criteria": { - "hsl": [ - [ - 79, - 163 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "green", - "greenish" - ], - "nouns": [ - "green" - ], - "description": ["Green is a cool, refreshing color that is often associated with nature, growth, and freshness. It is the color of grass, leaves, and trees, and it is often used to create a sense of harmony and balance. Some people may associate the color green with feelings of jealousy or envy, while others may associate it with feelings of peace and tranquility. In terms of wavelength, green is a primary color of light, and it is located between blue and yellow on the visible light spectrum. It is often used in art and design to create a sense of growth and renewal. Overall, green is a versatile and popular color that can be used to create a wide range of moods and atmospheres."], - "meanings": [ - "safety", - "harmony", - "stability", - "reliability", - "balance" - ], - "usage": [ - "relax", - "ballance", - "revitalize", - "encourage", - "posses" - ] - }, - { - "criteria": { - "hsl": [ - [ - 163, - 193 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "cyan" - ], - "nouns": [ - "cyan", - "sky blue" - ], - "description": ["Cyan is a bright, fresh color that is often associated with the ocean, the sky, and the natural world. It is a pale shade of blue that is similar to teal, but it is slightly lighter and more muted. Some people may associate the color cyan with feelings of peace and serenity, while others may associate it with feelings of youth and playfulness. In terms of wavelength, cyan is a mixture of blue and green light, and it is often used in art and design to create a sense of freshness and vitality. Overall, cyan is a versatile and refreshing color that can be used to create a wide range of moods and atmospheres."], - "meanings": [ - "freedom", - "trust", - "wisdom", - "joy", - "refreshing", - "consciousness", - "stimulating" - ], - "usage": [ - "self expression", - "communication", - "children products", - "technology", - "aerospace", - "entertainment", - "productivity" - ] - }, - { - "criteria": { - "hsl": [ - [ - 193, - 240 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "blue", - "blueish" - ], - "nouns": [ - "blue" - ], - "description": ["Blue is a cool, calming color that is often associated with trust, reliability, and intelligence. It is the color of the sky and the ocean, and it is often used to create a sense of peace and tranquility. Some people may associate the color blue with feelings of sadness or melancholy, while others may associate it with feelings of calm and relaxation. In terms of wavelength, blue is a primary color of light, and it is located between green and violet on the visible light spectrum. It is often used in art and design to create a sense of balance and harmony. Overall, blue is a versatile and popular color that can be used to create a wide range of moods and atmospheres."], - "meanings": [ - "trust", - "responsibility", - "honesty", - "loyalty", - "security", - "relying", - "calmness", - "control" - ], - "usage": [ - "security", - "finance", - "technology", - "health care", - "accounting" - ] - }, - { - "criteria": { - "hsl": [ - [ - 240, - 260 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "indigo" - ], - "nouns": [ - "indigo" - ], - "description": ["Indigo is a deep, rich color that is often associated with spirituality, intuition, and wisdom. It is a dark shade of blue that is similar to navy, but it is slightly lighter and more muted. Some people may associate the color indigo with feelings of calm and relaxation, while others may associate it with feelings of mystery and intrigue. In terms of wavelength, indigo is a deep blue color that is located between blue and violet on the visible light spectrum. It is often used in art and design to add a touch of depth and complexity. Overall, indigo is a beautiful and versatile color that can be used to create a wide range of moods and atmospheres."], - "meanings": [ - "spirituality", - "structure", - "compassion", - "sensitivity", - "mystery", - "tolerance", - "integrity", - "order", - "wisdom", - "inspiration" - ], - "usage": [ - "luxury", - "religion", - "psychic" - ] - }, - { - "criteria": { - "hsl": [ - [ - 260, - 270 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "violet" - ], - "nouns": [ - "violet" - ], - "description": ["Violet is a rich, regal color that is often associated with luxury, royalty, and sophistication. It is a deep shade of purple that is similar to lavender, but it is slightly darker and more intense. Some people may associate the color violet with feelings of mystery and spirituality, while others may associate it with feelings of calm and tranquility. In terms of wavelength, violet is a mixture of blue and red light, and it is often used in art and design to add a touch of elegance and refinement. Overall, violet is a beautiful and sophisticated color that can be used to create a calm and peaceful atmosphere."], - "meanings": [ - "spirituality", - "structure", - "compassion", - "sensitivity", - "mystery", - "tolerance", - "integrity", - "order", - "wisdom", - "inspiration" - ], - "usage": [ - "luxury", - "religion", - "psychic" - ] - }, - { - "criteria": { - "hsl": [ - [ - 270, - 291 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "purple", - "purplish" - ], - "nouns": [ - "purple" - ], - "description": ["Purple is a rich and vibrant color that is often associated with royalty, luxury, and creativity. It is a combination of blue and red, with more red than blue, giving it a warm and passionate quality. The shade of purple can vary from a deep, dark hue to a light, almost lavender color, and each shade can evoke different emotions and meanings. Some people may associate purple with spirituality and mysticism, while others may see it as a symbol of extravagance and decadence. In terms of wavelength, purple is located between blue and violet on the visible light spectrum and has a shorter wavelength than most other colors. Because of its striking and eye-catching nature, purple is frequently used in fashion, art, and design to add a pop of color and flair. Overall, purple is a captivating and dynamic color that can express a wide range of moods and emotions, making it a favorite among many people."], - "meanings": [ - "spirituality", - "structure", - "compassion", - "sensitivity", - "mystery", - "tolerance", - "integrity", - "order", - "wisdom", - "inspiration" - ], - "usage": [ - "luxury", - "religion", - "psychic", - "royalty" - ] - }, - { - "criteria": { - "hsl": [ - [ - 291, - 327 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "magenta" - ], - "nouns": [ - "magenta" - ], - "description": ["Magenta is a deep, rich color that is often associated with creativity, passion, and intensity. It is a vibrant shade of pink that is similar to fuchsia, but it is slightly darker and more muted. Some people may associate the color magenta with feelings of excitement and energy, while others may associate it with feelings of love and romance. In terms of wavelength, magenta is a mixture of red and blue light, and it is often used in art and design to add a bold and striking touch. Overall, magenta is a vibrant and lively color that can be used to add drama and excitement to any setting."], - "meanings": [ - "support", - "kind", - "change", - "harmony", - "kink", - "charm", - "politeness", - "sensitivity", - "tenderness", - "sweetness", - "femininity", - "romance", - "seductiveness", - "sexiness" - ], - "usage": [ - "children products", - , - "erotica" - ] - }, - { - "criteria": { - "hsl": [ - [ - 327, - 344 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "pink" - ], - "nouns": [ - "pink" - ], - "description": ["Pink is a light, delicate color that is often associated with femininity, romance, and sweetness. It is a pale shade of red, and it is often described as a softer, more gentle version of the color. Some people may associate the color pink with feelings of happiness and playfulness, while others may associate it with feelings of warmth and comfort. In terms of wavelength, pink is a mixture of red and white light, and it is often used in decorations and clothing to add a touch of whimsy and fun. Overall, pink is a cheerful and playful color that can be used to create a warm and inviting atmosphere."], - "meanings": [ - "support", - "kindness", - "change", - "harmony", - "kink", - "charme", - "politeness", - "sensitivity", - "tenderness", - "sweetness", - "femininity", - "romance", - "seductiveness", - "sexiness" - ], - "usage": [ - "children products", - "erotica" - ] - }, - { - "criteria": { - "hsl": [ - [ - 344, - 360 - ], - [ - 0.1, - 1 - ], - [ - 0.07, - 0.99 - ] - ] - }, - "descriptive": [ - "red", - "reddish" - ], - "nouns": [ - "red" - ], - "description": ["Red is a warm, vibrant color that is often associated with passion and excitement. It is the color of fire, and it is often used to grab attention and convey a sense of urgency or danger. In terms of wavelength, red is the color that is associated with the longest wavelengths of visible light, and it is one of the primary colors of light, along with blue and green. Some people may associate the color red with feelings of love and warmth, while others may associate it with anger or danger. Overall, red is a bold and striking color that can be used to convey a wide range of emotions and messages."], - "meanings": [ - "excitement", - "energy", - "passion", - "courage", - "attention", - "lust", - "power", - "love", - "speed", - "anger", - "lust", - "excitement", - "danger", - "ferocity", - "violence", - "fury", - "anger", - "vigor", - "urgency" - ], - "usage": [ - "stimulate", - "create urgency", - "draw attention", - "caution", - "encourage" - ] - } - ], - "temperatures": [ - { - "value": 1800, - "descriptive": ["ultra warm"] - }, - { - "value": 2400, - "descriptive": ["very warm"] - }, - { - "value": 2700, - "descriptive": ["warm"] - }, - { - "value": 3e3, - "descriptive": ["warm white"] - }, - { - "value": 4e3, - "descriptive": ["cool or cold"] - }, - { - "value": 6500, - "descriptive": ["cool"] - } - ], - "percentWords": [ - { - "maxPercentile": 0.06, - "word": "a dash of" - }, - { - "maxPercentile": 0.16, - "word": "a little bit of" - }, - { - "maxPercentile": 0.31, - "word": "some" - }, - { - "maxPercentile": 0.56, - "word": "a good bit of" - }, - { - "maxPercentile": 0.71, - "word": "a lot of" - }, - { - "maxPercentile": 0.86, - "word": "a whole lot of" - }, - { - "maxPercentile": 0.99, - "word": "neatly entirely" - }, - { - "maxPercentile": 1, - "word": "entirely" - } - ] - }; - - // src/index.js - var isInRange = (x, min, max) => x >= min && x <= max; - var randomizeArr = (arr) => [...arr].sort(() => 0.5 - Math.random()); - var _parseColor, parseColor_fn, _getWords, getWords_fn; - var ColorDescription = class { - constructor(color, words = en_default) { - __privateAdd(this, _parseColor); - __privateAdd(this, _getWords); - this.color = color; - this.descriptions = words.descriptions; - this.temperatures = words.temperatures; - this.percentWords = words.percentWords; - } - set color(color) { - this.currentColor = __privateMethod(this, _parseColor, parseColor_fn).call(this, color); - } - get color() { - return this.currentColor; - } - get temeratureWords() { - const goal = this.color.temperature(); - return this.temperatures.reduce((prev, curr) => Math.abs(curr.value - goal) < Math.abs(prev.value - goal) ? curr : prev, { value: 0 }); - } - percentages(model = "gl") { - const props = this.color[model](); - if (model === "gl") { - props.pop(); - } - const total = props.reduce((r, d) => r + d, 0); - return props.map((c) => total ? c / total : 0); - } - percentageWords(model = "gl") { - return this.percentages(model).map((component) => this.percentWords.find((words) => words.maxPercentile >= component).word); - } - get descriptiveWords() { - return __privateMethod(this, _getWords, getWords_fn).call(this, "descriptive"); - } - get nouns() { - return __privateMethod(this, _getWords, getWords_fn).call(this, "nouns"); - } - get meanings() { - return __privateMethod(this, _getWords, getWords_fn).call(this, "meanings"); - } - get usage() { - return __privateMethod(this, _getWords, getWords_fn).call(this, "usage"); - } - get description() { - return __privateMethod(this, _getWords, getWords_fn).call(this, "description"); - } - get bestContrast() { - return import_chroma_js.default.contrast(this.color, "black") > import_chroma_js.default.contrast(this.color, "white") ? "black" : "white"; - } - getDescriptiveList(random, limit) { - let arr = [...this.descriptiveWords]; - if (random) { - arr = randomizeArr(arr); - } - if (limit) { - arr = arr.slice(0, limit); - } - if (arr.length > 1) { - const last = arr.pop(); - return `${arr.join(", ")} and ${last}`; - } else { - return arr[0]; - } - } - }; - _parseColor = new WeakSet(); - parseColor_fn = function(color) { - if (import_chroma_js.default.valid(color)) { - return (0, import_chroma_js.default)(color); - } else { - throw new TypeError("Color is not a valid color, check the chroma.js documentation.", "color-description", 14); - } - }; - _getWords = new WeakSet(); - getWords_fn = function(scope = "descriptive", randomize = false, wordLimit) { - return this.descriptions.reduce((rem, current) => { - if (!current.hasOwnProperty(scope)) { - return rem; - } - const colorModels = Object.keys(current.criteria); - const matchesEveryCriteria = colorModels.every((colorModel) => { - const colorAsModel = this.color[colorModel](); - if (colorModel === "hsl" || colorModel === "gl" || colorModel === "rgb") { - colorAsModel.pop(); - } - return current.criteria[colorModel].every((criterium, i) => { - if (criterium === null) { - return true; - } else if (Array.isArray(criterium)) { - return isInRange(colorAsModel[i], criterium[0], criterium[1]); - } else if (!isNaN(criterium)) { - return colorAsModel[i] === criterium; - } else { - return false; - } - }); - }); - if (matchesEveryCriteria) { - return [...new Set([...rem, ...current[scope]])]; - } else { - return rem; - } - }, []); - }; - var src_default = ColorDescription; - return src_exports; -})(); +var ColorDescription=(()=>{var qn=Object.create;var ye=Object.defineProperty;var Gn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var Cn=Object.getPrototypeOf,Dn=Object.prototype.hasOwnProperty;var Lr=k=>ye(k,"__esModule",{value:!0});var Jn=typeof require!="undefined"?require:k=>{throw new Error('Dynamic require of "'+k+'" is not supported')};var Tn=(k,m)=>()=>(m||k((m={exports:{}}).exports,m),m.exports),Wn=(k,m)=>{Lr(k);for(var F in m)ye(k,F,{get:m[F],enumerable:!0})},jn=(k,m,F)=>{if(m&&typeof m=="object"||typeof m=="function")for(let R of Sn(m))!Dn.call(k,R)&&R!=="default"&&ye(k,R,{get:()=>m[R],enumerable:!(F=Gn(m,R))||F.enumerable});return k},Bn=k=>jn(Lr(ye(k!=null?qn(Cn(k)):{},"default",k&&k.__esModule&&"default"in k?{get:()=>k.default,enumerable:!0}:{value:k,enumerable:!0})),k);var Yn=(k,m,F)=>{if(!m.has(k))throw TypeError("Cannot "+F)};var Ye=(k,m,F)=>{if(m.has(k))throw TypeError("Cannot add the same private member more than once");m instanceof WeakSet?m.add(k):m.set(k,F)};var ee=(k,m,F)=>(Yn(k,m,"access private method"),F);var Or=Tn((Xe,He)=>{(function(k,m){typeof Xe=="object"&&typeof He!="undefined"?He.exports=m():typeof define=="function"&&define.amd?define(m):k.chroma=m()})(Xe,function(){"use strict";for(var k=function(e,r,a){return r===void 0&&(r=0),a===void 0&&(a=1),ea?a:e},m=function(e){e._clipped=!1,e._unclipped=e.slice(0);for(var r=0;r<=3;r++)r<3?((e[r]<0||e[r]>255)&&(e._clipped=!0),e[r]=k(e[r],0,255)):r===3&&(e[r]=k(e[r],0,1));return e},F={},R=0,j=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];R=3?Array.prototype.slice.call(e):J(e[0])=="object"&&r?r.split("").filter(function(a){return e[0][a]!==void 0}).map(function(a){return e[0][a]}):e[0]},Q=function(e){if(e.length<2)return null;var r=e.length-1;return J(e[r])=="string"?e[r].toLowerCase():null},X=Math.PI,v={clip_rgb:m,limit:k,type:J,unpack:Ve,last:Q,PI:X,TWOPI:X*2,PITHIRD:X/3,DEG2RAD:X/180,RAD2DEG:180/X},_={format:{},autodetect:[]},Sr=v.last,Cr=v.clip_rgb,Ue=v.type,Ze=function(){for(var r=[],a=arguments.length;a--;)r[a]=arguments[a];var t=this;if(Ue(r[0])==="object"&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var i=Sr(r),s=!1;if(!i){s=!0,_.sorted||(_.autodetect=_.autodetect.sort(function(u,c){return c.p-u.p}),_.sorted=!0);for(var n=0,o=_.autodetect;n4?e[4]:1;return s===1?[0,0,0,n]:[a>=1?0:255*(1-a)*(1-s),t>=1?0:255*(1-t)*(1-s),i>=1?0:255*(1-i)*(1-s),n]},Yr=Br,Xr=v.unpack,Hr=v.type;h.prototype.cmyk=function(){return Wr(this._rgb)},b.cmyk=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["cmyk"])))},_.format.cmyk=Yr,_.autodetect.push({p:2,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e=Xr(e,"cmyk"),Hr(e)==="array"&&e.length===4)return"cmyk"}});var Vr=v.unpack,Ur=v.last,ke=function(e){return Math.round(e*100)/100},Zr=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=Vr(e,"hsla"),t=Ur(e)||"lsa";return a[0]=ke(a[0]||0),a[1]=ke(a[1]*100)+"%",a[2]=ke(a[2]*100)+"%",t==="hsla"||a.length>3&&a[3]<1?(a[3]=a.length>3?a[3]:1,t="hsla"):a.length=3,t+"("+a.join(",")+")"},Jr=Zr,Qr=v.unpack,Kr=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];e=Qr(e,"rgba");var a=e[0],t=e[1],i=e[2];a/=255,t/=255,i/=255;var s=Math.min(a,t,i),n=Math.max(a,t,i),o=(n+s)/2,l,f;return n===s?(l=0,f=Number.NaN):l=o<.5?(n-s)/(n+s):(n-s)/(2-n-s),a==n?f=(t-i)/(n-s):t==n?f=2+(i-a)/(n-s):i==n&&(f=4+(a-t)/(n-s)),f*=60,f<0&&(f+=360),e.length>3&&e[3]!==void 0?[f,l,o,e[3]]:[f,l,o]},Qe=Kr,ea=v.unpack,ra=v.last,_e=Math.round,aa=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=ea(e,"rgba"),t=ra(e)||"rgb";return t.substr(0,3)=="hsl"?Jr(Qe(a),t):(a[0]=_e(a[0]),a[1]=_e(a[1]),a[2]=_e(a[2]),(t==="rgba"||a.length>3&&a[3]<1)&&(a[3]=a.length>3?a[3]:1,t="rgba"),t+"("+a.slice(0,t==="rgb"?3:4).join(",")+")")},ta=aa,na=v.unpack,xe=Math.round,ia=function(){for(var e,r=[],a=arguments.length;a--;)r[a]=arguments[a];r=na(r,"hsl");var t=r[0],i=r[1],s=r[2],n,o,l;if(i===0)n=o=l=s*255;else{var f=[0,0,0],u=[0,0,0],c=s<.5?s*(1+i):s+i-s*i,p=2*s-c,g=t/360;f[0]=g+1/3,f[1]=g,f[2]=g-1/3;for(var w=0;w<3;w++)f[w]<0&&(f[w]+=1),f[w]>1&&(f[w]-=1),6*f[w]<1?u[w]=p+(c-p)*6*f[w]:2*f[w]<1?u[w]=c:3*f[w]<2?u[w]=p+(c-p)*(2/3-f[w])*6:u[w]=p;e=[xe(u[0]*255),xe(u[1]*255),xe(u[2]*255)],n=e[0],o=e[1],l=e[2]}return r.length>3?[n,o,l,r[3]]:[n,o,l,1]},Ie=ia,Ke=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,er=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,rr=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ar=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,tr=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,nr=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,ir=Math.round,sr=function(e){e=e.toLowerCase().trim();var r;if(_.format.named)try{return _.format.named(e)}catch(w){}if(r=e.match(Ke)){for(var a=r.slice(1,4),t=0;t<3;t++)a[t]=+a[t];return a[3]=1,a}if(r=e.match(er)){for(var i=r.slice(1,5),s=0;s<4;s++)i[s]=+i[s];return i}if(r=e.match(rr)){for(var n=r.slice(1,4),o=0;o<3;o++)n[o]=ir(n[o]*2.55);return n[3]=1,n}if(r=e.match(ar)){for(var l=r.slice(1,5),f=0;f<3;f++)l[f]=ir(l[f]*2.55);return l[3]=+l[3],l}if(r=e.match(tr)){var u=r.slice(1,4);u[1]*=.01,u[2]*=.01;var c=Ie(u);return c[3]=1,c}if(r=e.match(nr)){var p=r.slice(1,4);p[1]*=.01,p[2]*=.01;var g=Ie(p);return g[3]=+r[4],g}};sr.test=function(e){return Ke.test(e)||er.test(e)||rr.test(e)||ar.test(e)||tr.test(e)||nr.test(e)};var or=sr,sa=v.type;h.prototype.css=function(e){return ta(this._rgb,e)},b.css=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["css"])))},_.format.css=or,_.autodetect.push({p:5,test:function(e){for(var r=[],a=arguments.length-1;a-- >0;)r[a]=arguments[a+1];if(!r.length&&sa(e)==="string"&&or.test(e))return"css"}});var oa=v.unpack;_.format.gl=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=oa(e,"rgba");return a[0]*=255,a[1]*=255,a[2]*=255,a},b.gl=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["gl"])))},h.prototype.gl=function(){var e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]};var la=v.unpack,fa=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=la(e,"rgb"),t=a[0],i=a[1],s=a[2],n=Math.min(t,i,s),o=Math.max(t,i,s),l=o-n,f=l*100/255,u=n/(255-l)*100,c;return l===0?c=Number.NaN:(t===o&&(c=(i-s)/l),i===o&&(c=2+(s-t)/l),s===o&&(c=4+(t-i)/l),c*=60,c<0&&(c+=360)),[c,f,u]},ca=fa,ua=v.unpack,da=Math.floor,ha=function(){for(var e,r,a,t,i,s,n=[],o=arguments.length;o--;)n[o]=arguments[o];n=ua(n,"hcg");var l=n[0],f=n[1],u=n[2],c,p,g;u=u*255;var w=f*255;if(f===0)c=p=g=u;else{l===360&&(l=0),l>360&&(l-=360),l<0&&(l+=360),l/=60;var M=da(l),x=l-M,E=u*(1-f),z=E+w*(1-x),G=E+w*x,S=E+w;switch(M){case 0:e=[S,G,E],c=e[0],p=e[1],g=e[2];break;case 1:r=[z,S,E],c=r[0],p=r[1],g=r[2];break;case 2:a=[E,S,G],c=a[0],p=a[1],g=a[2];break;case 3:t=[E,z,S],c=t[0],p=t[1],g=t[2];break;case 4:i=[G,E,S],c=i[0],p=i[1],g=i[2];break;case 5:s=[S,E,z],c=s[0],p=s[1],g=s[2];break}}return[c,p,g,n.length>3?n[3]:1]},va=ha,ga=v.unpack,pa=v.type;h.prototype.hcg=function(){return ca(this._rgb)},b.hcg=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["hcg"])))},_.format.hcg=va,_.autodetect.push({p:1,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e=ga(e,"hcg"),pa(e)==="array"&&e.length===3)return"hcg"}});var ba=v.unpack,ma=v.last,he=Math.round,ya=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=ba(e,"rgba"),t=a[0],i=a[1],s=a[2],n=a[3],o=ma(e)||"auto";n===void 0&&(n=1),o==="auto"&&(o=n<1?"rgba":"rgb"),t=he(t),i=he(i),s=he(s);var l=t<<16|i<<8|s,f="000000"+l.toString(16);f=f.substr(f.length-6);var u="0"+he(n*255).toString(16);switch(u=u.substr(u.length-2),o.toLowerCase()){case"rgba":return"#"+f+u;case"argb":return"#"+u+f;default:return"#"+f}},lr=ya,wa=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,ka=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,_a=function(e){if(e.match(wa)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);var r=parseInt(e,16),a=r>>16,t=r>>8&255,i=r&255;return[a,t,i,1]}if(e.match(ka)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);var s=parseInt(e,16),n=s>>24&255,o=s>>16&255,l=s>>8&255,f=Math.round((s&255)/255*100)/100;return[n,o,l,f]}throw new Error("unknown hex color: "+e)},fr=_a,xa=v.type;h.prototype.hex=function(e){return lr(this._rgb,e)},b.hex=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["hex"])))},_.format.hex=fr,_.autodetect.push({p:4,test:function(e){for(var r=[],a=arguments.length-1;a-- >0;)r[a]=arguments[a+1];if(!r.length&&xa(e)==="string"&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return"hex"}});var Ia=v.unpack,cr=v.TWOPI,Ma=Math.min,Na=Math.sqrt,$a=Math.acos,Fa=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=Ia(e,"rgb"),t=a[0],i=a[1],s=a[2];t/=255,i/=255,s/=255;var n,o=Ma(t,i,s),l=(t+i+s)/3,f=l>0?1-o/l:0;return f===0?n=NaN:(n=(t-i+(t-s))/2,n/=Na((t-i)*(t-i)+(t-s)*(i-s)),n=$a(n),s>i&&(n=cr-n),n/=cr),[n*360,f,l]},Ea=Fa,Pa=v.unpack,Me=v.limit,re=v.TWOPI,Ne=v.PITHIRD,ae=Math.cos,Aa=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];e=Pa(e,"hsi");var a=e[0],t=e[1],i=e[2],s,n,o;return isNaN(a)&&(a=0),isNaN(t)&&(t=0),a>360&&(a-=360),a<0&&(a+=360),a/=360,a<1/3?(o=(1-t)/3,s=(1+t*ae(re*a)/ae(Ne-re*a))/3,n=1-(o+s)):a<2/3?(a-=1/3,s=(1-t)/3,n=(1+t*ae(re*a)/ae(Ne-re*a))/3,o=1-(s+n)):(a-=2/3,n=(1-t)/3,o=(1+t*ae(re*a)/ae(Ne-re*a))/3,s=1-(n+o)),s=Me(i*s*3),n=Me(i*n*3),o=Me(i*o*3),[s*255,n*255,o*255,e.length>3?e[3]:1]},Ra=Aa,za=v.unpack,La=v.type;h.prototype.hsi=function(){return Ea(this._rgb)},b.hsi=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["hsi"])))},_.format.hsi=Ra,_.autodetect.push({p:2,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e=za(e,"hsi"),La(e)==="array"&&e.length===3)return"hsi"}});var Oa=v.unpack,qa=v.type;h.prototype.hsl=function(){return Qe(this._rgb)},b.hsl=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["hsl"])))},_.format.hsl=Ie,_.autodetect.push({p:2,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e=Oa(e,"hsl"),qa(e)==="array"&&e.length===3)return"hsl"}});var Ga=v.unpack,Sa=Math.min,Ca=Math.max,Da=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];e=Ga(e,"rgb");var a=e[0],t=e[1],i=e[2],s=Sa(a,t,i),n=Ca(a,t,i),o=n-s,l,f,u;return u=n/255,n===0?(l=Number.NaN,f=0):(f=o/n,a===n&&(l=(t-i)/o),t===n&&(l=2+(i-a)/o),i===n&&(l=4+(a-t)/o),l*=60,l<0&&(l+=360)),[l,f,u]},Ta=Da,Wa=v.unpack,ja=Math.floor,Ba=function(){for(var e,r,a,t,i,s,n=[],o=arguments.length;o--;)n[o]=arguments[o];n=Wa(n,"hsv");var l=n[0],f=n[1],u=n[2],c,p,g;if(u*=255,f===0)c=p=g=u;else{l===360&&(l=0),l>360&&(l-=360),l<0&&(l+=360),l/=60;var w=ja(l),M=l-w,x=u*(1-f),E=u*(1-f*M),z=u*(1-f*(1-M));switch(w){case 0:e=[u,z,x],c=e[0],p=e[1],g=e[2];break;case 1:r=[E,u,x],c=r[0],p=r[1],g=r[2];break;case 2:a=[x,u,z],c=a[0],p=a[1],g=a[2];break;case 3:t=[x,E,u],c=t[0],p=t[1],g=t[2];break;case 4:i=[z,x,u],c=i[0],p=i[1],g=i[2];break;case 5:s=[u,x,E],c=s[0],p=s[1],g=s[2];break}}return[c,p,g,n.length>3?n[3]:1]},Ya=Ba,Xa=v.unpack,Ha=v.type;h.prototype.hsv=function(){return Ta(this._rgb)},b.hsv=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["hsv"])))},_.format.hsv=Ya,_.autodetect.push({p:2,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e=Xa(e,"hsv"),Ha(e)==="array"&&e.length===3)return"hsv"}});var C={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},Va=v.unpack,ur=Math.pow,Ua=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=Va(e,"rgb"),t=a[0],i=a[1],s=a[2],n=Za(t,i,s),o=n[0],l=n[1],f=n[2],u=116*l-16;return[u<0?0:u,500*(o-l),200*(l-f)]},$e=function(e){return(e/=255)<=.04045?e/12.92:ur((e+.055)/1.055,2.4)},Fe=function(e){return e>C.t3?ur(e,1/3):e/C.t2+C.t0},Za=function(e,r,a){e=$e(e),r=$e(r),a=$e(a);var t=Fe((.4124564*e+.3575761*r+.1804375*a)/C.Xn),i=Fe((.2126729*e+.7151522*r+.072175*a)/C.Yn),s=Fe((.0193339*e+.119192*r+.9503041*a)/C.Zn);return[t,i,s]},dr=Ua,Ja=v.unpack,Qa=Math.pow,Ka=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];e=Ja(e,"lab");var a=e[0],t=e[1],i=e[2],s,n,o,l,f,u;return n=(a+16)/116,s=isNaN(t)?n:n+t/500,o=isNaN(i)?n:n-i/200,n=C.Yn*Pe(n),s=C.Xn*Pe(s),o=C.Zn*Pe(o),l=Ee(3.2404542*s-1.5371385*n-.4985314*o),f=Ee(-.969266*s+1.8760108*n+.041556*o),u=Ee(.0556434*s-.2040259*n+1.0572252*o),[l,f,u,e.length>3?e[3]:1]},Ee=function(e){return 255*(e<=.00304?12.92*e:1.055*Qa(e,1/2.4)-.055)},Pe=function(e){return e>C.t1?e*e*e:C.t2*(e-C.t0)},hr=Ka,et=v.unpack,rt=v.type;h.prototype.lab=function(){return dr(this._rgb)},b.lab=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["lab"])))},_.format.lab=hr,_.autodetect.push({p:2,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e=et(e,"lab"),rt(e)==="array"&&e.length===3)return"lab"}});var at=v.unpack,tt=v.RAD2DEG,nt=Math.sqrt,it=Math.atan2,st=Math.round,ot=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=at(e,"lab"),t=a[0],i=a[1],s=a[2],n=nt(i*i+s*s),o=(it(s,i)*tt+360)%360;return st(n*1e4)===0&&(o=Number.NaN),[t,n,o]},lt=ot,ft=v.unpack,ct=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=ft(e,"rgb"),t=a[0],i=a[1],s=a[2],n=dr(t,i,s),o=n[0],l=n[1],f=n[2];return lt(o,l,f)},vr=ct,ut=v.unpack,dt=v.DEG2RAD,ht=Math.sin,vt=Math.cos,gt=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=ut(e,"lch"),t=a[0],i=a[1],s=a[2];return isNaN(s)&&(s=0),s=s*dt,[t,vt(s)*i,ht(s)*i]},pt=gt,bt=v.unpack,mt=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];e=bt(e,"lch");var a=e[0],t=e[1],i=e[2],s=pt(a,t,i),n=s[0],o=s[1],l=s[2],f=hr(n,o,l),u=f[0],c=f[1],p=f[2];return[u,c,p,e.length>3?e[3]:1]},gr=mt,yt=v.unpack,wt=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=yt(e,"hcl").reverse();return gr.apply(void 0,a)},kt=wt,_t=v.unpack,xt=v.type;h.prototype.lch=function(){return vr(this._rgb)},h.prototype.hcl=function(){return vr(this._rgb).reverse()},b.lch=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["lch"])))},b.hcl=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["hcl"])))},_.format.lch=gr,_.format.hcl=kt,["lch","hcl"].forEach(function(e){return _.autodetect.push({p:2,test:function(){for(var r=[],a=arguments.length;a--;)r[a]=arguments[a];if(r=_t(r,e),xt(r)==="array"&&r.length===3)return e}})});var It={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},te=It,Mt=v.type;h.prototype.name=function(){for(var e=lr(this._rgb,"rgb"),r=0,a=Object.keys(te);r0;)r[a]=arguments[a+1];if(!r.length&&Mt(e)==="string"&&te[e.toLowerCase()])return"named"}});var Nt=v.unpack,$t=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=Nt(e,"rgb"),t=a[0],i=a[1],s=a[2];return(t<<16)+(i<<8)+s},Ft=$t,Et=v.type,Pt=function(e){if(Et(e)=="number"&&e>=0&&e<=16777215){var r=e>>16,a=e>>8&255,t=e&255;return[r,a,t,1]}throw new Error("unknown num color: "+e)},At=Pt,Rt=v.type;h.prototype.num=function(){return Ft(this._rgb)},b.num=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["num"])))},_.format.num=At,_.autodetect.push({p:5,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e.length===1&&Rt(e[0])==="number"&&e[0]>=0&&e[0]<=16777215)return"num"}});var pr=v.unpack,br=v.type,mr=Math.round;h.prototype.rgb=function(e){return e===void 0&&(e=!0),e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(mr)},h.prototype.rgba=function(e){return e===void 0&&(e=!0),this._rgb.slice(0,4).map(function(r,a){return a<3?e===!1?r:mr(r):r})},b.rgb=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["rgb"])))},_.format.rgb=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];var a=pr(e,"rgba");return a[3]===void 0&&(a[3]=1),a},_.autodetect.push({p:3,test:function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];if(e=pr(e,"rgba"),br(e)==="array"&&(e.length===3||e.length===4&&br(e[3])=="number"&&e[3]>=0&&e[3]<=1))return"rgb"}});var ve=Math.log,zt=function(e){var r=e/100,a,t,i;return r<66?(a=255,t=-155.25485562709179-.44596950469579133*(t=r-2)+104.49216199393888*ve(t),i=r<20?0:-254.76935184120902+.8274096064007395*(i=r-10)+115.67994401066147*ve(i)):(a=351.97690566805693+.114206453784165*(a=r-55)-40.25366309332127*ve(a),t=325.4494125711974+.07943456536662342*(t=r-50)-28.0852963507957*ve(t),i=255),[a,t,i,1]},yr=zt,Lt=v.unpack,Ot=Math.round,qt=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];for(var a=Lt(e,"rgb"),t=a[0],i=a[2],s=1e3,n=4e4,o=.4,l;n-s>o;){l=(n+s)*.5;var f=yr(l);f[2]/f[0]>=i/t?n=l:s=l}return Ot(l)},Gt=qt;h.prototype.temp=h.prototype.kelvin=h.prototype.temperature=function(){return Gt(this._rgb)},b.temp=b.kelvin=b.temperature=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(e,["temp"])))},_.format.temp=_.format.kelvin=_.format.temperature=yr;var St=v.type;h.prototype.alpha=function(e,r){return r===void 0&&(r=!1),e!==void 0&&St(e)==="number"?r?(this._rgb[3]=e,this):new h([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]},h.prototype.clipped=function(){return this._rgb._clipped||!1},h.prototype.darken=function(e){e===void 0&&(e=1);var r=this,a=r.lab();return a[0]-=C.Kn*e,new h(a,"lab").alpha(r.alpha(),!0)},h.prototype.brighten=function(e){return e===void 0&&(e=1),this.darken(-e)},h.prototype.darker=h.prototype.darken,h.prototype.brighter=h.prototype.brighten,h.prototype.get=function(e){var r=e.split("."),a=r[0],t=r[1],i=this[a]();if(t){var s=a.indexOf(t);if(s>-1)return i[s];throw new Error("unknown channel "+t+" in mode "+a)}else return i};var Ct=v.type,Dt=Math.pow,Tt=1e-7,Wt=20;h.prototype.luminance=function(e){if(e!==void 0&&Ct(e)==="number"){if(e===0)return new h([0,0,0,this._rgb[3]],"rgb");if(e===1)return new h([255,255,255,this._rgb[3]],"rgb");var r=this.luminance(),a="rgb",t=Wt,i=function(n,o){var l=n.interpolate(o,.5,a),f=l.luminance();return Math.abs(e-f)e?i(n,l):i(l,o)},s=(r>e?i(new h([0,0,0]),this):i(this,new h([255,255,255]))).rgb();return new h(s.concat([this._rgb[3]]))}return jt.apply(void 0,this._rgb.slice(0,3))};var jt=function(e,r,a){return e=Ae(e),r=Ae(r),a=Ae(a),.2126*e+.7152*r+.0722*a},Ae=function(e){return e/=255,e<=.03928?e/12.92:Dt((e+.055)/1.055,2.4)},D={},wr=v.type,kr=function(e,r,a){a===void 0&&(a=.5);for(var t=[],i=arguments.length-3;i-- >0;)t[i]=arguments[i+3];var s=t[0]||"lrgb";if(!D[s]&&!t.length&&(s=Object.keys(D)[0]),!D[s])throw new Error("interpolation mode "+s+" is not defined");return wr(e)!=="object"&&(e=new h(e)),wr(r)!=="object"&&(r=new h(r)),D[s](e,r,a).alpha(e.alpha()+a*(r.alpha()-e.alpha()))};h.prototype.mix=h.prototype.interpolate=function(e,r){r===void 0&&(r=.5);for(var a=[],t=arguments.length-2;t-- >0;)a[t]=arguments[t+2];return kr.apply(void 0,[this,e,r].concat(a))},h.prototype.premultiply=function(e){e===void 0&&(e=!1);var r=this._rgb,a=r[3];return e?(this._rgb=[r[0]*a,r[1]*a,r[2]*a,a],this):new h([r[0]*a,r[1]*a,r[2]*a,a],"rgb")},h.prototype.saturate=function(e){e===void 0&&(e=1);var r=this,a=r.lch();return a[1]+=C.Kn*e,a[1]<0&&(a[1]=0),new h(a,"lch").alpha(r.alpha(),!0)},h.prototype.desaturate=function(e){return e===void 0&&(e=1),this.saturate(-e)};var _r=v.type;h.prototype.set=function(e,r,a){a===void 0&&(a=!1);var t=e.split("."),i=t[0],s=t[1],n=this[i]();if(s){var o=i.indexOf(s);if(o>-1){if(_r(r)=="string")switch(r.charAt(0)){case"+":n[o]+=+r;break;case"-":n[o]+=+r;break;case"*":n[o]*=+r.substr(1);break;case"/":n[o]/=+r.substr(1);break;default:n[o]=+r}else if(_r(r)==="number")n[o]=r;else throw new Error("unsupported value for Color.set");var l=new h(n,i);return a?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+s+" in mode "+i)}else return n};var Bt=function(e,r,a){var t=e._rgb,i=r._rgb;return new h(t[0]+a*(i[0]-t[0]),t[1]+a*(i[1]-t[1]),t[2]+a*(i[2]-t[2]),"rgb")};D.rgb=Bt;var Re=Math.sqrt,ne=Math.pow,Yt=function(e,r,a){var t=e._rgb,i=t[0],s=t[1],n=t[2],o=r._rgb,l=o[0],f=o[1],u=o[2];return new h(Re(ne(i,2)*(1-a)+ne(l,2)*a),Re(ne(s,2)*(1-a)+ne(f,2)*a),Re(ne(n,2)*(1-a)+ne(u,2)*a),"rgb")};D.lrgb=Yt;var Xt=function(e,r,a){var t=e.lab(),i=r.lab();return new h(t[0]+a*(i[0]-t[0]),t[1]+a*(i[1]-t[1]),t[2]+a*(i[2]-t[2]),"lab")};D.lab=Xt;var oe=function(e,r,a,t){var i,s,n,o;t==="hsl"?(n=e.hsl(),o=r.hsl()):t==="hsv"?(n=e.hsv(),o=r.hsv()):t==="hcg"?(n=e.hcg(),o=r.hcg()):t==="hsi"?(n=e.hsi(),o=r.hsi()):(t==="lch"||t==="hcl")&&(t="hcl",n=e.hcl(),o=r.hcl());var l,f,u,c,p,g;t.substr(0,1)==="h"&&(i=n,l=i[0],u=i[1],p=i[2],s=o,f=s[0],c=s[1],g=s[2]);var w,M,x,E;return!isNaN(l)&&!isNaN(f)?(f>l&&f-l>180?E=f-(l+360):f180?E=f+360-l:E=f-l,M=l+a*E):isNaN(l)?isNaN(f)?M=Number.NaN:(M=f,(p==1||p==0)&&t!="hsv"&&(w=c)):(M=l,(g==1||g==0)&&t!="hsv"&&(w=u)),w===void 0&&(w=u+a*(c-u)),x=p+a*(g-p),new h([M,w,x],t)},xr=function(e,r,a){return oe(e,r,a,"lch")};D.lch=xr,D.hcl=xr;var Ht=function(e,r,a){var t=e.num(),i=r.num();return new h(t+a*(i-t),"num")};D.num=Ht;var Vt=function(e,r,a){return oe(e,r,a,"hcg")};D.hcg=Vt;var Ut=function(e,r,a){return oe(e,r,a,"hsi")};D.hsi=Ut;var Zt=function(e,r,a){return oe(e,r,a,"hsl")};D.hsl=Zt;var Jt=function(e,r,a){return oe(e,r,a,"hsv")};D.hsv=Jt;var Qt=v.clip_rgb,ze=Math.pow,Le=Math.sqrt,Oe=Math.PI,Ir=Math.cos,Mr=Math.sin,Kt=Math.atan2,en=function(e,r,a){r===void 0&&(r="lrgb"),a===void 0&&(a=null);var t=e.length;a||(a=Array.from(new Array(t)).map(function(){return 1}));var i=t/a.reduce(function(M,x){return M+x});if(a.forEach(function(M,x){a[x]*=i}),e=e.map(function(M){return new h(M)}),r==="lrgb")return rn(e,a);for(var s=e.shift(),n=s.get(r),o=[],l=0,f=0,u=0;u=360;)w-=360;n[g]=w}else n[g]=n[g]/o[g];return p/=t,new h(n,r).alpha(p>.99999?1:p,!0)},rn=function(e,r){for(var a=e.length,t=[0,0,0,0],i=0;i.9999999&&(t[3]=1),new h(Qt(t))},ie=v.type,an=Math.pow,ge=function(e){var r="rgb",a=b("#ccc"),t=0,i=[0,1],s=[],n=[0,0],o=!1,l=[],f=!1,u=0,c=1,p=!1,g={},w=!0,M=1,x=function(d){if(d=d||["#fff","#000"],d&&ie(d)==="string"&&b.brewer&&b.brewer[d.toLowerCase()]&&(d=b.brewer[d.toLowerCase()]),ie(d)==="array"){d.length===1&&(d=[d[0],d[0]]),d=d.slice(0);for(var y=0;y=o[N];)N++;return N-1}return 0},z=function(d){return d},G=function(d){return d},S=function(d,y){var N,I;if(y==null&&(y=!1),isNaN(d)||d===null)return a;if(y)I=d;else if(o&&o.length>2){var T=E(d);I=T/(o.length-2)}else c!==u?I=(d-u)/(c-u):I=1;I=G(I),y||(I=z(I)),M!==1&&(I=an(I,M)),I=n[0]+I*(1-n[0]-n[1]),I=Math.min(1,Math.max(0,I));var O=Math.floor(I*1e4);if(w&&g[O])N=g[O];else{if(ie(l)==="array")for(var P=0;P=A&&P===s.length-1){N=l[P];break}if(I>A&&I2){var P=d.map(function(q,L){return L/(d.length-1)}),A=d.map(function(q){return(q-u)/(c-u)});A.every(function(q,L){return P[L]===q})||(G=function(q){if(q<=0||q>=1)return q;for(var L=0;q>=A[L+1];)L++;var U=(q-A[L])/(A[L+1]-A[L]),se=P[L]+U*(P[L+1]-P[L]);return se})}}return i=[u,c],$},$.mode=function(d){return arguments.length?(r=d,W(),$):r},$.range=function(d,y){return x(d,y),$},$.out=function(d){return f=d,$},$.spread=function(d){return arguments.length?(t=d,$):t},$.correctLightness=function(d){return d==null&&(d=!0),p=d,W(),p?z=function(y){for(var N=S(0,!0).lab()[0],I=S(1,!0).lab()[0],T=N>I,O=S(y,!0).lab()[0],P=N+(I-N)*y,A=O-P,q=0,L=1,U=20;Math.abs(A)>.01&&U-- >0;)(function(){return T&&(A*=-1),A<0?(q=y,y+=(L-y)*.5):(L=y,y+=(q-y)*.5),O=S(y,!0).lab()[0],A=O-P})();return y}:z=function(y){return y},$},$.padding=function(d){return d!=null?(ie(d)==="number"&&(d=[d,d]),n=d,$):n},$.colors=function(d,y){arguments.length<2&&(y="hex");var N=[];if(arguments.length===0)N=l.slice(0);else if(d===1)N=[$(.5)];else if(d>1){var I=i[0],T=i[1]-I;N=tn(0,d,!1).map(function(L){return $(I+L/(d-1)*T)})}else{e=[];var O=[];if(o&&o.length>2)for(var P=1,A=o.length,q=1<=A;q?PA;q?P++:P--)O.push((o[P-1]+o[P])*.5);else O=i;N=O.map(function(L){return $(L)})}return b[y]&&(N=N.map(function(L){return L[y]()})),N},$.cache=function(d){return d!=null?(w=d,$):w},$.gamma=function(d){return d!=null?(M=d,$):M},$.nodata=function(d){return d!=null?(a=b(d),$):a},$};function tn(e,r,a){for(var t=[],i=es;i?n++:n--)t.push(n);return t}var qe=function(e){var r,a,t,i,s,n,o;if(e=e.map(function(c){return new h(c)}),e.length===2)r=e.map(function(c){return c.lab()}),s=r[0],n=r[1],i=function(c){var p=[0,1,2].map(function(g){return s[g]+c*(n[g]-s[g])});return new h(p,"lab")};else if(e.length===3)a=e.map(function(c){return c.lab()}),s=a[0],n=a[1],o=a[2],i=function(c){var p=[0,1,2].map(function(g){return(1-c)*(1-c)*s[g]+2*(1-c)*c*n[g]+c*c*o[g]});return new h(p,"lab")};else if(e.length===4){var l;t=e.map(function(c){return c.lab()}),s=t[0],n=t[1],o=t[2],l=t[3],i=function(c){var p=[0,1,2].map(function(g){return(1-c)*(1-c)*(1-c)*s[g]+3*(1-c)*(1-c)*c*n[g]+3*(1-c)*c*c*o[g]+c*c*c*l[g]});return new h(p,"lab")}}else if(e.length===5){var f=qe(e.slice(0,3)),u=qe(e.slice(2,5));i=function(c){return c<.5?f(c*2):u((c-.5)*2)}}return i},nn=function(e){var r=qe(e);return r.scale=function(){return ge(r)},r},B=function(e,r,a){if(!B[a])throw new Error("unknown blend mode "+a);return B[a](e,r)},H=function(e){return function(r,a){var t=b(a).rgb(),i=b(r).rgb();return b.rgb(e(t,i))}},V=function(e){return function(r,a){var t=[];return t[0]=e(r[0],a[0]),t[1]=e(r[1],a[1]),t[2]=e(r[2],a[2]),t}},sn=function(e){return e},on=function(e,r){return e*r/255},ln=function(e,r){return e>r?r:e},fn=function(e,r){return e>r?e:r},cn=function(e,r){return 255*(1-(1-e/255)*(1-r/255))},un=function(e,r){return r<128?2*e*r/255:255*(1-2*(1-e/255)*(1-r/255))},dn=function(e,r){return 255*(1-(1-r/255)/(e/255))},hn=function(e,r){return e===255?255:(e=255*(r/255)/(1-e/255),e>255?255:e)};B.normal=H(V(sn)),B.multiply=H(V(on)),B.screen=H(V(cn)),B.overlay=H(V(un)),B.darken=H(V(ln)),B.lighten=H(V(fn)),B.dodge=H(V(hn)),B.burn=H(V(dn));for(var vn=B,Ge=v.type,gn=v.clip_rgb,pn=v.TWOPI,bn=Math.pow,mn=Math.sin,yn=Math.cos,wn=function(e,r,a,t,i){e===void 0&&(e=300),r===void 0&&(r=-1.5),a===void 0&&(a=1),t===void 0&&(t=1),i===void 0&&(i=[0,1]);var s=0,n;Ge(i)==="array"?n=i[1]-i[0]:(n=0,i=[i,i]);var o=function(l){var f=pn*((e+120)/360+r*l),u=bn(i[0]+n*l,t),c=s!==0?a[0]+l*s:a,p=c*u*(1-u)/2,g=yn(f),w=mn(f),M=u+p*(-.14861*g+1.78277*w),x=u+p*(-.29227*g-.90649*w),E=u+p*(1.97294*g);return b(gn([M*255,x*255,E*255,1]))};return o.start=function(l){return l==null?e:(e=l,o)},o.rotations=function(l){return l==null?r:(r=l,o)},o.gamma=function(l){return l==null?t:(t=l,o)},o.hue=function(l){return l==null?a:(a=l,Ge(a)==="array"?(s=a[1]-a[0],s===0&&(a=a[1])):s=0,o)},o.lightness=function(l){return l==null?i:(Ge(l)==="array"?(i=l,n=l[1]-l[0]):(i=[l,l],n=0),o)},o.scale=function(){return b.scale(o)},o.hue(a),o},kn="0123456789abcdef",_n=Math.floor,xn=Math.random,In=function(){for(var e="#",r=0;r<6;r++)e+=kn.charAt(_n(xn()*16));return new h(e,"hex")},Nr=Math.log,Mn=Math.pow,Nn=Math.floor,$n=Math.abs,$r=function(e,r){r===void 0&&(r=null);var a={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return J(e)==="object"&&(e=Object.values(e)),e.forEach(function(t){r&&J(t)==="object"&&(t=t[r]),t!=null&&!isNaN(t)&&(a.values.push(t),a.sum+=t,ta.max&&(a.max=t),a.count+=1)}),a.domain=[a.min,a.max],a.limits=function(t,i){return Fr(a,t,i)},a},Fr=function(e,r,a){r===void 0&&(r="equal"),a===void 0&&(a=7),J(e)=="array"&&(e=$r(e));var t=e.min,i=e.max,s=e.values.sort(function(je,Be){return je-Be});if(a===1)return[t,i];var n=[];if(r.substr(0,1)==="c"&&(n.push(t),n.push(i)),r.substr(0,1)==="e"){n.push(t);for(var o=1;o 0");var l=Math.LOG10E*Nr(t),f=Math.LOG10E*Nr(i);n.push(t);for(var u=1;u200&&(G=!1)}for(var le={},De=0;Det?(a+.05)/(t+.05):(t+.05)/(a+.05)},pe=Math.sqrt,En=Math.atan2,Pr=Math.abs,Ar=Math.cos,Se=Math.PI,Pn=function(e,r,a,t){a===void 0&&(a=1),t===void 0&&(t=1),e=new h(e),r=new h(r);for(var i=Array.from(e.lab()),s=i[0],n=i[1],o=i[2],l=Array.from(r.lab()),f=l[0],u=l[1],c=l[2],p=pe(n*n+o*o),g=pe(u*u+c*c),w=s<16?.511:.040975*s/(1+.01765*s),M=.0638*p/(1+.0131*p)+.638,x=p<1e-6?0:En(o,n)*180/Se;x<0;)x+=360;for(;x>=360;)x-=360;var E=x>=164&&x<=345?.56+Pr(.2*Ar(Se*(x+168)/180)):.36+Pr(.4*Ar(Se*(x+35)/180)),z=p*p*p*p,G=pe(z/(z+1900)),S=M*(G*E+1-G),W=s-f,$=p-g,d=n-u,y=o-c,N=d*d+y*y-$*$,I=W/(a*w),T=$/(t*M),O=S;return pe(I*I+T*T+N/(O*O))},An=function(e,r,a){a===void 0&&(a="lab"),e=new h(e),r=new h(r);var t=e.get(a),i=r.get(a),s=0;for(var n in t){var o=(t[n]||0)-(i[n]||0);s+=o*o}return Math.sqrt(s)},Rn=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];try{return new(Function.prototype.bind.apply(h,[null].concat(e))),!0}catch(a){return!1}},zn={cool:function(){return ge([b.hsl(180,1,.9),b.hsl(250,.7,.4)])},hot:function(){return ge(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")}},be={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Ce=0,Rr=Object.keys(be);CeUn});var ce=Bn(Or());var qr={descriptions:[{criteria:{hsl:[null,[.75,1],[.4,.55]]},descriptive:["saturated","strong","lush","ablaze","beaming","bold","brilliant","flamboyant","vibrant","vivid","loud"]},{criteria:{hsl:[null,null,[0,.07]]},descriptive:["dark","ashy","somber","bleak","muddy","sooty"]},{criteria:{hsl:[null,null,[0,.3]]},descriptive:["dark","dim","gloomy","dull"]},{criteria:{hsl:[null,[.1,.7],[.15,.5]]},descriptive:["bleak","muted","matte","dusty"]},{criteria:{hsl:[null,[.12,1],[.7,1]]},descriptive:["tinted"]},{criteria:{hsl:[null,[.2,1],[.75,.95]]},descriptive:["pastel"]},{criteria:{hsl:[null,null,[.88,1]]},descriptive:["pale","light","faded","delicate","glistening","bleached"]},{criteria:{hsl:[null,[.5,1],[.7,.9]]},descriptive:["fresh","sparkling","glittering","glowing","jazzy","opalescent"]},{criteria:{hsl:[null,null,[.9,1]]},descriptive:["neutral"]},{criteria:{hsl:[null,[.74,1],[.9,1]]},descriptive:["muted"]},{criteria:{hsl:[null,null,1]},descriptive:["colorless","bright","brilliant","high"]},{criteria:{hsl:[null,null,0]},descriptive:["colorless","low","dark"]},{criteria:{hsl:[null,[0,.01],null]},descriptive:["colorless","neutral"]},{criteria:{hsl:[null,null,[.01,.3]]},descriptive:["shady"]},{criteria:{hsl:[null,[0,.4],null]},descriptive:["ashy","dusty"]},{criteria:{hsl:[null,null,[.01,.08]]},descriptive:["almost black"]},{criteria:{hsl:[null,null,[0,.02]]},descriptive:["black"]},{criteria:{hsl:[null,null,[0,.09]]},descriptive:["very dark"]},{criteria:{hsl:[null,[0,.4],[0,.22]]},descriptive:["dark"]},{criteria:{hsl:[null,[.1,.4],[0,.6]]},descriptive:["dark","inky","dim","gloomy"]},{criteria:{hsl:[null,[0,.04],[.1,.99]]},descriptive:["grey"]},{criteria:{hsl:[null,[.04,.1],[.17,.99]]},descriptive:["almost grey"]},{criteria:{hsl:[null,[.1,.3],[.17,.99]]},descriptive:["very unsaturated"]},{criteria:{hsl:[null,[.3,.46],null]},descriptive:["unsaturated"]},{criteria:{hsl:[null,[.46,.6],[.4,.55]]},descriptive:["rather unsaturated"]},{criteria:{hsl:[null,[.601,.8],[.45,.6]]},descriptive:["saturated"]},{criteria:{hsl:[null,[.801,.94],[.45,.6]]},descriptive:["rather saturated"]},{criteria:{hsl:[null,[.941,1],[.45,.6]]},descriptive:["very saturated"]},{criteria:{hsl:[[0,90],[.3,1],[.1,1]]},descriptive:["warm","mellow"]},{criteria:{hsl:[[270,360],[.3,1],[.1,1]]},descriptive:["warm","mellow"]},{criteria:{hsl:[[90.01,269.99],null,[.1,1]]},descriptive:["cold","cool"]},{criteria:{hsl:[null,null,[.98,1]]},nouns:["white"],description:["White is a color that is often associated with purity, innocence, and cleanliness. It is the lightest color on the visible spectrum and is often described as having a bright, luminous quality. When you think of white, you might imagine a freshly fallen snow, a blank canvas, or a cloudless sky. It is a versatile color that can be used in a wide range of settings and contexts, from formal to casual. If you close your eyes and picture white, you might imagine a bright, radiant light that illuminates everything around it."],meanings:["purity","cleanliness","simplicity","innocence","freshness","light","goodness","virtue","safety","peace","tranquility","wholeness","perfection","honesty","truth","sincerity"],usage:["health","hospital","sanitary"]},{criteria:{hsl:[null,null,[0,.08]]},nouns:["black"],description:["Black is a color that is often associated with power, elegance, and sophistication. It is a color that is often used to create a sense of mystery, depth, and contrast, and it is often described as a color that can be both bold and elegant. In art and design, black is often used to create a sense of sophistication and drama, and it is often used in fashion to create a sense of sophistication and refinement."],meanings:["power","control","authority","discipline","discretion","secrecy","elegance","mystery"],usage:["intimidate","create fear","authority","luxury"]},{criteria:{hsl:[[0,15],[.1,1],[.07,.99]]},descriptive:["red","reddish"],nouns:["red"],description:["Red is a warm, vibrant color that is often associated with passion and excitement. It is the color of fire, and it is often used to grab attention and convey a sense of urgency or danger. In terms of wavelength, red is the color that is associated with the longest wavelengths of visible light, and it is one of the primary colors of light, along with blue and green. Some people may associate the color red with feelings of love and warmth, while others may associate it with anger or danger. Overall, red is a bold and striking color that can be used to convey a wide range of emotions and messages."],meanings:["excitement","energy","passion","courage","attention","lust","power","love","speed","anger","lust","excitement","danger","ferocity","violence","fury","anger","vigor","urgency"],usage:["stimulate","create urgency","draw attention","caution","encourage","excite"]},{criteria:{hsl:[[15,45],[.1,1],[.4,.99]]},descriptive:["orange"],nouns:["orange"],description:["Orange is a vibrant and playful color that is often associated with creativity, energy, and warmth. It is a secondary color that is made by combining red and yellow, and it is often described as a warm and friendly color that can be both invigorating and calming. It is often associated with joy, enthusiasm, and warmth, and it is often used in art and design to create a sense of excitement and playfulness."],meanings:["optimism","independence","adventure","creativity","fun"],usage:["stimulate","draw attention","express freedom","fascinate"]},{criteria:{hsl:[[15,45],[.1,1],[.07,.4]]},descriptive:["brown"],nouns:["brown"],description:["Brown is a warm and earthy color that is often associated with nature, stability, and reliability. It is a secondary color that is made by combining red, blue, and yellow in different proportions, and it is often described as a rich and luxurious color that can be both comforting and grounding. It is often associated with wood, soil, and the natural world, and it is often used in art and design to create a sense of warmth and permanence."],meanings:["strength","reliability","resilience","loneliness","sadness","isolation","warmth","comfort","security"],usage:["agriculture","legal","food","tobacco","alcohol"]},{criteria:{hsl:[[45,70],[.1,1],[.07,.99]]},descriptive:["yellow"],nouns:["yellow"],description:["Yellow is a bright and cheerful color that is often associated with sunshine, happiness, and warmth. It is a primary color that is made by combining red and green light, and it is usually described as a warm and vibrant color that can be both calming and energizing. It is often associated with joy, happiness, and friendship, and it is often used in art and design to create a sense of cheerfulness and playfulness."],meanings:["enthusiasm","opportunity","spontaneity","happiness","positivity"],usage:["stimulate","relax","awake awareness","energize","affect mood","sale","cheap","budget","construction","convey competence"]},{criteria:{hsl:[[70,79],[.1,1],[.07,.99]]},descriptive:["lime"],nouns:["lime"],description:["Lime is a bright, vibrant color that is often associated with freshness, energy, and youth. It is a pale shade of green that is similar to chartreuse, but it is slightly lighter and more vibrant. Some people may associate the color lime with feelings of playfulness and excitement, while others may associate it with feelings of rejuvenation and renewal. In terms of wavelength, lime is a mixture of green and yellow light, and it is often used in art and design to create a sense of energy and vitality. Overall, lime is a lively and refreshing color that can be used to create a wide range of moods and atmospheres."],meanings:["growth","harmony","fertility","kindness","dependability"],usage:["restore energy","promote growth","awake awareness","rejuvenate","nature"]},{criteria:{hsl:[[79,163],[.1,1],[.07,.99]]},descriptive:["green","greenish"],nouns:["green"],description:["Green is a cool, refreshing color that is often associated with nature, growth, and freshness. It is the color of grass, leaves, and trees, and it is often used to create a sense of harmony and balance. Some people may associate the color green with feelings of jealousy or envy, while others may associate it with feelings of peace and tranquility. In terms of wavelength, green is a primary color of light, and it is located between blue and yellow on the visible light spectrum. It is often used in art and design to create a sense of growth and renewal. Overall, green is a versatile and popular color that can be used to create a wide range of moods and atmospheres."],meanings:["safety","harmony","stability","reliability","balance"],usage:["relax","ballance","revitalize","encourage","posses"]},{criteria:{hsl:[[163,193],[.1,1],[.07,.99]]},descriptive:["cyan"],nouns:["cyan","sky blue"],description:["Cyan is a bright, fresh color that is often associated with the ocean, the sky, and the natural world. It is a pale shade of blue that is similar to teal, but it is slightly lighter and more muted. Some people may associate the color cyan with feelings of peace and serenity, while others may associate it with feelings of youth and playfulness. In terms of wavelength, cyan is a mixture of blue and green light, and it is often used in art and design to create a sense of freshness and vitality. Overall, cyan is a versatile and refreshing color that can be used to create a wide range of moods and atmospheres."],meanings:["freedom","trust","wisdom","joy","refreshing","consciousness","stimulating"],usage:["self expression","communication","children products","technology","aerospace","entertainment","productivity"]},{criteria:{hsl:[[193,240],[.1,1],[.07,.99]]},descriptive:["blue","blueish"],nouns:["blue"],description:["Blue is a cool, calming color that is often associated with trust, reliability, and intelligence. It is the color of the sky and the ocean, and it is often used to create a sense of peace and tranquility. Some people may associate the color blue with feelings of sadness or melancholy, while others may associate it with feelings of calm and relaxation. In terms of wavelength, blue is a primary color of light, and it is located between green and violet on the visible light spectrum. It is often used in art and design to create a sense of balance and harmony. Overall, blue is a versatile and popular color that can be used to create a wide range of moods and atmospheres."],meanings:["trust","responsibility","honesty","loyalty","security","relying","calmness","control"],usage:["security","finance","technology","health care","accounting"]},{criteria:{hsl:[[240,260],[.1,1],[.07,.99]]},descriptive:["indigo"],nouns:["indigo"],description:["Indigo is a deep, rich color that is often associated with spirituality, intuition, and wisdom. It is a dark shade of blue that is similar to navy, but it is slightly lighter and more muted. Some people may associate the color indigo with feelings of calm and relaxation, while others may associate it with feelings of mystery and intrigue. In terms of wavelength, indigo is a deep blue color that is located between blue and violet on the visible light spectrum. It is often used in art and design to add a touch of depth and complexity. Overall, indigo is a beautiful and versatile color that can be used to create a wide range of moods and atmospheres."],meanings:["spirituality","structure","compassion","sensitivity","mystery","tolerance","integrity","order","wisdom","inspiration"],usage:["luxury","religion","psychic"]},{criteria:{hsl:[[260,270],[.1,1],[.07,.99]]},descriptive:["violet"],nouns:["violet"],description:["Violet is a rich, regal color that is often associated with luxury, royalty, and sophistication. It is a deep shade of purple that is similar to lavender, but it is slightly darker and more intense. Some people may associate the color violet with feelings of mystery and spirituality, while others may associate it with feelings of calm and tranquility. In terms of wavelength, violet is a mixture of blue and red light, and it is often used in art and design to add a touch of elegance and refinement. Overall, violet is a beautiful and sophisticated color that can be used to create a calm and peaceful atmosphere."],meanings:["spirituality","structure","compassion","sensitivity","mystery","tolerance","integrity","order","wisdom","inspiration"],usage:["luxury","religion","psychic"]},{criteria:{hsl:[[270,291],[.1,1],[.07,.99]]},descriptive:["purple","purplish"],nouns:["purple"],description:["Purple is a rich and vibrant color that is often associated with royalty, luxury, and creativity. It is a combination of blue and red, with more red than blue, giving it a warm and passionate quality. The shade of purple can vary from a deep, dark hue to a light, almost lavender color, and each shade can evoke different emotions and meanings. Some people may associate purple with spirituality and mysticism, while others may see it as a symbol of extravagance and decadence. In terms of wavelength, purple is located between blue and violet on the visible light spectrum and has a shorter wavelength than most other colors. Because of its striking and eye-catching nature, purple is frequently used in fashion, art, and design to add a pop of color and flair. Overall, purple is a captivating and dynamic color that can express a wide range of moods and emotions, making it a favorite among many people."],meanings:["spirituality","structure","compassion","sensitivity","mystery","tolerance","integrity","order","wisdom","inspiration"],usage:["luxury","religion","psychic","royalty"]},{criteria:{hsl:[[291,327],[.1,1],[.07,.99]]},descriptive:["magenta"],nouns:["magenta"],description:["Magenta is a deep, rich color that is often associated with creativity, passion, and intensity. It is a vibrant shade of pink that is similar to fuchsia, but it is slightly darker and more muted. Some people may associate the color magenta with feelings of excitement and energy, while others may associate it with feelings of love and romance. In terms of wavelength, magenta is a mixture of red and blue light, and it is often used in art and design to add a bold and striking touch. Overall, magenta is a vibrant and lively color that can be used to add drama and excitement to any setting."],meanings:["support","kind","change","harmony","kink","charm","politeness","sensitivity","tenderness","sweetness","femininity","romance","seductiveness","sexiness"],usage:["children products",,"erotica"]},{criteria:{hsl:[[327,344],[.1,1],[.07,.99]]},descriptive:["pink"],nouns:["pink"],description:["Pink is a light, delicate color that is often associated with femininity, romance, and sweetness. It is a pale shade of red, and it is often described as a softer, more gentle version of the color. Some people may associate the color pink with feelings of happiness and playfulness, while others may associate it with feelings of warmth and comfort. In terms of wavelength, pink is a mixture of red and white light, and it is often used in decorations and clothing to add a touch of whimsy and fun. Overall, pink is a cheerful and playful color that can be used to create a warm and inviting atmosphere."],meanings:["support","kindness","change","harmony","kink","charme","politeness","sensitivity","tenderness","sweetness","femininity","romance","seductiveness","sexiness"],usage:["children products","erotica"]},{criteria:{hsl:[[344,360],[.1,1],[.07,.99]]},descriptive:["red","reddish"],nouns:["red"],description:["Red is a warm, vibrant color that is often associated with passion and excitement. It is the color of fire, and it is often used to grab attention and convey a sense of urgency or danger. In terms of wavelength, red is the color that is associated with the longest wavelengths of visible light, and it is one of the primary colors of light, along with blue and green. Some people may associate the color red with feelings of love and warmth, while others may associate it with anger or danger. Overall, red is a bold and striking color that can be used to convey a wide range of emotions and messages."],meanings:["excitement","energy","passion","courage","attention","lust","power","love","speed","anger","lust","excitement","danger","ferocity","violence","fury","anger","vigor","urgency"],usage:["stimulate","create urgency","draw attention","caution","encourage"]}],temperatures:[{value:1800,descriptive:["ultra warm"]},{value:2400,descriptive:["very warm"]},{value:2700,descriptive:["warm"]},{value:3e3,descriptive:["warm white"]},{value:4e3,descriptive:["cool or cold"]},{value:6500,descriptive:["cool"]}],percentWords:[{maxPercentile:.06,word:"a dash of"},{maxPercentile:.16,word:"a little bit of"},{maxPercentile:.31,word:"some"},{maxPercentile:.56,word:"a good bit of"},{maxPercentile:.71,word:"a lot of"},{maxPercentile:.86,word:"a whole lot of"},{maxPercentile:.99,word:"neatly entirely"},{maxPercentile:1,word:"entirely"}]};var Xn=(k,m,F)=>k>=m&&k<=F,Hn=k=>[...k].sort(()=>.5-Math.random()),we,Vn,Z,ue,Gr=class{constructor(m,F=qr){Ye(this,we);Ye(this,Z);this.color=m,this.descriptions=F.descriptions,this.temperatures=F.temperatures,this.percentWords=F.percentWords}set color(m){this.currentColor=ee(this,we,Vn).call(this,m)}get color(){return this.currentColor}get temeratureWords(){let m=this.color.temperature();return this.temperatures.reduce((F,R)=>Math.abs(R.value-m)j+Y,0);return F.map(j=>R?j/R:0)}percentageWords(m="gl"){return this.percentages(m).map(F=>this.percentWords.find(R=>R.maxPercentile>=F).word)}get descriptiveWords(){return ee(this,Z,ue).call(this,"descriptive")}get nouns(){return ee(this,Z,ue).call(this,"nouns")}get meanings(){return ee(this,Z,ue).call(this,"meanings")}get usage(){return ee(this,Z,ue).call(this,"usage")}get description(){return ee(this,Z,ue).call(this,"description")}get bestContrast(){return ce.default.contrast(this.color,"black")>ce.default.contrast(this.color,"white")?"black":"white"}getDescriptiveList(m,F){let R=[...this.descriptiveWords];if(m&&(R=Hn(R)),F&&(R=R.slice(0,F)),R.length>1){let j=R.pop();return`${R.join(", ")} and ${j}`}else return R[0]}};we=new WeakSet,Vn=function(m){if(ce.default.valid(m))return(0,ce.default)(m);throw new TypeError("Color is not a valid color, check the chroma.js documentation.","color-description",14)},Z=new WeakSet,ue=function(m="descriptive",F=!1,R){return this.descriptions.reduce((j,Y)=>Y.hasOwnProperty(m)&&Object.keys(Y.criteria).every(Q=>{let X=this.color[Q]();return(Q==="hsl"||Q==="gl"||Q==="rgb")&&X.pop(),Y.criteria[Q].every((v,_)=>v===null?!0:Array.isArray(v)?Xn(X[_],v[0],v[1]):isNaN(v)?!1:X[_]===v)})?[...new Set([...j,...Y[m]])]:j,[])};var Un=Gr;return Zn;})(); /** * chroma.js - JavaScript library for color conversions * diff --git a/package-lock.json b/package-lock.json index 9a79a20..f60ba04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "color-description", - "version": "0.9.0", + "version": "0.12.0", "license": "MIT", "dependencies": { "chroma-js": "^2.1.2" diff --git a/package.json b/package.json index d23476e..855655d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build:esm": "esbuild src/index.js --outfile=dist/index.esm.js --format=esm --bundle --target=es2020 --minify", "build:browser": "esbuild src/index.js --outfile=dist/index.iife.js --bundle --target=es6 --format=iife --global-name=ColorDescription --minify", "build:node": "esbuild src/index.js --outfile=dist/index.js --platform=node --target=node14 --minify", - "test": "npm run build && node --experimental-vm-modules node_modules/.bin/jest", + "test": "npm run build && node --experimental-vm-modules node_modules/.bin/jest --verbose ./tests", "dev:watch": "esbuild src/index.js --outfile=dist/index.iife.js --bundle --target=es6 --format=iife --global-name=ColorDescription --watch", "dev:watch-demo": "live-server ./dist --entry-file=dist/index.html --watch=dist/index.html,./dist/index.iife.js", "dev": "concurrently \"npm run dev:watch\" \"npm run dev:watch-demo\"" diff --git a/tests/colorDescriptionLib.test.js b/tests/colorDescriptionLib.test.js new file mode 100644 index 0000000..3cf45de --- /dev/null +++ b/tests/colorDescriptionLib.test.js @@ -0,0 +1,111 @@ +import ColorDescription from "../src/index"; +import chroma from "chroma-js"; + +describe("ColorDescription Library", () => { + let colorDesc; + + beforeEach(() => { + colorDesc = new ColorDescription("#FF5733"); + }); + + /* + test("Constructor and color parsing", () => { + expect(colorDesc.color).toBeInstanceOf(chroma); + expect(colorDesc.color.hex()).toBe("#ff5733"); + + expect(() => new ColorDescription("not a color")).toThrow(TypeError); + });*/ + + test("Color setter", () => { + colorDesc.color = "#00FF00"; + expect(colorDesc.color.hex()).toBe("#00ff00"); + + expect(() => { + colorDesc.color = "invalid color"; + }).toThrow(TypeError); + }); + + test("Temperature words", () => { + const tempWords = colorDesc.temeratureWords; + expect(tempWords).toHaveProperty("value"); + expect(tempWords).toHaveProperty("descriptive"); + expect(Array.isArray(tempWords.descriptive)).toBe(true); + }); + + test("Percentages", () => { + const percentages = colorDesc.percentages(); + expect(Array.isArray(percentages)).toBe(true); + expect(percentages).toHaveLength(3); + percentages.forEach((percent) => { + expect(percent).toBeGreaterThanOrEqual(0); + expect(percent).toBeLessThanOrEqual(1); + }); + }); + + test("Percentage words", () => { + const percentWords = colorDesc.percentageWords(); + expect(Array.isArray(percentWords)).toBe(true); + expect(percentWords).toHaveLength(3); + percentWords.forEach((word) => { + expect(typeof word).toBe("string"); + }); + }); + + test("Descriptive words", () => { + const descriptiveWords = colorDesc.descriptiveWords; + expect(Array.isArray(descriptiveWords)).toBe(true); + descriptiveWords.forEach((word) => { + expect(typeof word).toBe("string"); + }); + }); + + test("Nouns", () => { + const nouns = colorDesc.nouns; + expect(Array.isArray(nouns)).toBe(true); + nouns.forEach((noun) => { + expect(typeof noun).toBe("string"); + }); + }); + + test("Meanings", () => { + const meanings = colorDesc.meanings; + expect(Array.isArray(meanings)).toBe(true); + meanings.forEach((meaning) => { + expect(typeof meaning).toBe("string"); + }); + }); + + test("Usage", () => { + const usage = colorDesc.usage; + expect(Array.isArray(usage)).toBe(true); + usage.forEach((use) => { + expect(typeof use).toBe("string"); + }); + }); + + test("Description", () => { + const description = colorDesc.description; + expect(Array.isArray(description)).toBe(true); + expect(description.length).toBeGreaterThanOrEqual(1); + description.forEach((desc) => { + expect(typeof desc).toBe("string"); + }); + }); + + test("Best contrast", () => { + const contrast = colorDesc.bestContrast; + expect(contrast).toMatch(/^(black|white)$/); + }); + + test("Get descriptive list", () => { + const list = colorDesc.getDescriptiveList(false, 3); + expect(typeof list).toBe("string"); + expect(list.split(",").length).toBeLessThanOrEqual(3); + }); + + test("Get descriptive list with randomization", () => { + const list1 = colorDesc.getDescriptiveList(true, 5); + const list2 = colorDesc.getDescriptiveList(true, 5); + expect(list1).not.toBe(list2); // This might occasionally fail due to randomness + }); +});