/******/ (function() { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 208: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* MIT license */ /* eslint-disable no-mixed-operators */ var cssKeywords = __webpack_require__(101); // NOTE: conversions should only return primitive values (i.e. arrays, or // values that give correct `typeof` results). // do not use box values types (i.e. Number(), String(), etc.) var reverseKeywords = {}; for (var _i = 0, _Object$keys = Object.keys(cssKeywords); _i < _Object$keys.length; _i++) { var key = _Object$keys[_i]; reverseKeywords[cssKeywords[key]] = key; } var convert = { rgb: { channels: 3, labels: 'rgb' }, hsl: { channels: 3, labels: 'hsl' }, hsv: { channels: 3, labels: 'hsv' }, hwb: { channels: 3, labels: 'hwb' }, cmyk: { channels: 4, labels: 'cmyk' }, xyz: { channels: 3, labels: 'xyz' }, lab: { channels: 3, labels: 'lab' }, lch: { channels: 3, labels: 'lch' }, hex: { channels: 1, labels: ['hex'] }, keyword: { channels: 1, labels: ['keyword'] }, ansi16: { channels: 1, labels: ['ansi16'] }, ansi256: { channels: 1, labels: ['ansi256'] }, hcg: { channels: 3, labels: ['h', 'c', 'g'] }, apple: { channels: 3, labels: ['r16', 'g16', 'b16'] }, gray: { channels: 1, labels: ['gray'] } }; module.exports = convert; // Hide .channels and .labels properties for (var _i2 = 0, _Object$keys2 = Object.keys(convert); _i2 < _Object$keys2.length; _i2++) { var model = _Object$keys2[_i2]; if (!('channels' in convert[model])) { throw new Error('missing channels property: ' + model); } if (!('labels' in convert[model])) { throw new Error('missing channel labels property: ' + model); } if (convert[model].labels.length !== convert[model].channels) { throw new Error('channel and label counts mismatch: ' + model); } var _convert$model = convert[model], channels = _convert$model.channels, labels = _convert$model.labels; delete convert[model].channels; delete convert[model].labels; Object.defineProperty(convert[model], 'channels', { value: channels }); Object.defineProperty(convert[model], 'labels', { value: labels }); } convert.rgb.hsl = function (rgb) { var r = rgb[0] / 255; var g = rgb[1] / 255; var b = rgb[2] / 255; var min = Math.min(r, g, b); var max = Math.max(r, g, b); var delta = max - min; var h; var s; if (max === min) { h = 0; } else if (r === max) { h = (g - b) / delta; } else if (g === max) { h = 2 + (b - r) / delta; } else if (b === max) { h = 4 + (r - g) / delta; } h = Math.min(h * 60, 360); if (h < 0) { h += 360; } var l = (min + max) / 2; if (max === min) { s = 0; } else if (l <= 0.5) { s = delta / (max + min); } else { s = delta / (2 - max - min); } return [h, s * 100, l * 100]; }; convert.rgb.hsv = function (rgb) { var rdif; var gdif; var bdif; var h; var s; var r = rgb[0] / 255; var g = rgb[1] / 255; var b = rgb[2] / 255; var v = Math.max(r, g, b); var diff = v - Math.min(r, g, b); var diffc = function diffc(c) { return (v - c) / 6 / diff + 1 / 2; }; if (diff === 0) { h = 0; s = 0; } else { s = diff / v; rdif = diffc(r); gdif = diffc(g); bdif = diffc(b); if (r === v) { h = bdif - gdif; } else if (g === v) { h = 1 / 3 + rdif - bdif; } else if (b === v) { h = 2 / 3 + gdif - rdif; } if (h < 0) { h += 1; } else if (h > 1) { h -= 1; } } return [h * 360, s * 100, v * 100]; }; convert.rgb.hwb = function (rgb) { var r = rgb[0]; var g = rgb[1]; var b = rgb[2]; var h = convert.rgb.hsl(rgb)[0]; var w = 1 / 255 * Math.min(r, Math.min(g, b)); b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); return [h, w * 100, b * 100]; }; convert.rgb.cmyk = function (rgb) { var r = rgb[0] / 255; var g = rgb[1] / 255; var b = rgb[2] / 255; var k = Math.min(1 - r, 1 - g, 1 - b); var c = (1 - r - k) / (1 - k) || 0; var m = (1 - g - k) / (1 - k) || 0; var y = (1 - b - k) / (1 - k) || 0; return [c * 100, m * 100, y * 100, k * 100]; }; function comparativeDistance(x, y) { /* See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance */ return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2); } convert.rgb.keyword = function (rgb) { var reversed = reverseKeywords[rgb]; if (reversed) { return reversed; } var currentClosestDistance = Infinity; var currentClosestKeyword; for (var _i3 = 0, _Object$keys3 = Object.keys(cssKeywords); _i3 < _Object$keys3.length; _i3++) { var keyword = _Object$keys3[_i3]; var value = cssKeywords[keyword]; // Compute comparative distance var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest if (distance < currentClosestDistance) { currentClosestDistance = distance; currentClosestKeyword = keyword; } } return currentClosestKeyword; }; convert.keyword.rgb = function (keyword) { return cssKeywords[keyword]; }; convert.rgb.xyz = function (rgb) { var r = rgb[0] / 255; var g = rgb[1] / 255; var b = rgb[2] / 255; // Assume sRGB r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92; g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92; b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92; var x = r * 0.4124 + g * 0.3576 + b * 0.1805; var y = r * 0.2126 + g * 0.7152 + b * 0.0722; var z = r * 0.0193 + g * 0.1192 + b * 0.9505; return [x * 100, y * 100, z * 100]; }; convert.rgb.lab = function (rgb) { var xyz = convert.rgb.xyz(rgb); var x = xyz[0]; var y = xyz[1]; var z = xyz[2]; x /= 95.047; y /= 100; z /= 108.883; x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116; y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116; z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116; var l = 116 * y - 16; var a = 500 * (x - y); var b = 200 * (y - z); return [l, a, b]; }; convert.hsl.rgb = function (hsl) { var h = hsl[0] / 360; var s = hsl[1] / 100; var l = hsl[2] / 100; var t2; var t3; var val; if (s === 0) { val = l * 255; return [val, val, val]; } if (l < 0.5) { t2 = l * (1 + s); } else { t2 = l + s - l * s; } var t1 = 2 * l - t2; var rgb = [0, 0, 0]; for (var i = 0; i < 3; i++) { t3 = h + 1 / 3 * -(i - 1); if (t3 < 0) { t3++; } if (t3 > 1) { t3--; } if (6 * t3 < 1) { val = t1 + (t2 - t1) * 6 * t3; } else if (2 * t3 < 1) { val = t2; } else if (3 * t3 < 2) { val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; } else { val = t1; } rgb[i] = val * 255; } return rgb; }; convert.hsl.hsv = function (hsl) { var h = hsl[0]; var s = hsl[1] / 100; var l = hsl[2] / 100; var smin = s; var lmin = Math.max(l, 0.01); l *= 2; s *= l <= 1 ? l : 2 - l; smin *= lmin <= 1 ? lmin : 2 - lmin; var v = (l + s) / 2; var sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s); return [h, sv * 100, v * 100]; }; convert.hsv.rgb = function (hsv) { var h = hsv[0] / 60; var s = hsv[1] / 100; var v = hsv[2] / 100; var hi = Math.floor(h) % 6; var f = h - Math.floor(h); var p = 255 * v * (1 - s); var q = 255 * v * (1 - s * f); var t = 255 * v * (1 - s * (1 - f)); v *= 255; switch (hi) { case 0: return [v, t, p]; case 1: return [q, v, p]; case 2: return [p, v, t]; case 3: return [p, q, v]; case 4: return [t, p, v]; case 5: return [v, p, q]; } }; convert.hsv.hsl = function (hsv) { var h = hsv[0]; var s = hsv[1] / 100; var v = hsv[2] / 100; var vmin = Math.max(v, 0.01); var sl; var l; l = (2 - s) * v; var lmin = (2 - s) * vmin; sl = s * vmin; sl /= lmin <= 1 ? lmin : 2 - lmin; sl = sl || 0; l /= 2; return [h, sl * 100, l * 100]; }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb convert.hwb.rgb = function (hwb) { var h = hwb[0] / 360; var wh = hwb[1] / 100; var bl = hwb[2] / 100; var ratio = wh + bl; var f; // Wh + bl cant be > 1 if (ratio > 1) { wh /= ratio; bl /= ratio; } var i = Math.floor(6 * h); var v = 1 - bl; f = 6 * h - i; if ((i & 0x01) !== 0) { f = 1 - f; } var n = wh + f * (v - wh); // Linear interpolation var r; var g; var b; /* eslint-disable max-statements-per-line,no-multi-spaces */ switch (i) { default: case 6: case 0: r = v; g = n; b = wh; break; case 1: r = n; g = v; b = wh; break; case 2: r = wh; g = v; b = n; break; case 3: r = wh; g = n; b = v; break; case 4: r = n; g = wh; b = v; break; case 5: r = v; g = wh; b = n; break; } /* eslint-enable max-statements-per-line,no-multi-spaces */ return [r * 255, g * 255, b * 255]; }; convert.cmyk.rgb = function (cmyk) { var c = cmyk[0] / 100; var m = cmyk[1] / 100; var y = cmyk[2] / 100; var k = cmyk[3] / 100; var r = 1 - Math.min(1, c * (1 - k) + k); var g = 1 - Math.min(1, m * (1 - k) + k); var b = 1 - Math.min(1, y * (1 - k) + k); return [r * 255, g * 255, b * 255]; }; convert.xyz.rgb = function (xyz) { var x = xyz[0] / 100; var y = xyz[1] / 100; var z = xyz[2] / 100; var r; var g; var b; r = x * 3.2406 + y * -1.5372 + z * -0.4986; g = x * -0.9689 + y * 1.8758 + z * 0.0415; b = x * 0.0557 + y * -0.2040 + z * 1.0570; // Assume sRGB r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92; g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92; b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92; r = Math.min(Math.max(0, r), 1); g = Math.min(Math.max(0, g), 1); b = Math.min(Math.max(0, b), 1); return [r * 255, g * 255, b * 255]; }; convert.xyz.lab = function (xyz) { var x = xyz[0]; var y = xyz[1]; var z = xyz[2]; x /= 95.047; y /= 100; z /= 108.883; x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116; y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116; z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116; var l = 116 * y - 16; var a = 500 * (x - y); var b = 200 * (y - z); return [l, a, b]; }; convert.lab.xyz = function (lab) { var l = lab[0]; var a = lab[1]; var b = lab[2]; var x; var y; var z; y = (l + 16) / 116; x = a / 500 + y; z = y - b / 200; var y2 = Math.pow(y, 3); var x2 = Math.pow(x, 3); var z2 = Math.pow(z, 3); y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; x *= 95.047; y *= 100; z *= 108.883; return [x, y, z]; }; convert.lab.lch = function (lab) { var l = lab[0]; var a = lab[1]; var b = lab[2]; var h; var hr = Math.atan2(b, a); h = hr * 360 / 2 / Math.PI; if (h < 0) { h += 360; } var c = Math.sqrt(a * a + b * b); return [l, c, h]; }; convert.lch.lab = function (lch) { var l = lch[0]; var c = lch[1]; var h = lch[2]; var hr = h / 360 * 2 * Math.PI; var a = c * Math.cos(hr); var b = c * Math.sin(hr); return [l, a, b]; }; convert.rgb.ansi16 = function (args) { var saturation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var _args = _slicedToArray(args, 3), r = _args[0], g = _args[1], b = _args[2]; var value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization value = Math.round(value / 50); if (value === 0) { return 30; } var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255)); if (value === 2) { ansi += 60; } return ansi; }; convert.hsv.ansi16 = function (args) { // Optimization here; we already know the value and don't need to get // it converted for us. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); }; convert.rgb.ansi256 = function (args) { var r = args[0]; var g = args[1]; var b = args[2]; // We use the extended greyscale palette here, with the exception of // black and white. normal palette only has 4 greyscale shades. if (r === g && g === b) { if (r < 8) { return 16; } if (r > 248) { return 231; } return Math.round((r - 8) / 247 * 24) + 232; } var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5); return ansi; }; convert.ansi16.rgb = function (args) { var color = args % 10; // Handle greyscale if (color === 0 || color === 7) { if (args > 50) { color += 3.5; } color = color / 10.5 * 255; return [color, color, color]; } var mult = (~~(args > 50) + 1) * 0.5; var r = (color & 1) * mult * 255; var g = (color >> 1 & 1) * mult * 255; var b = (color >> 2 & 1) * mult * 255; return [r, g, b]; }; convert.ansi256.rgb = function (args) { // Handle greyscale if (args >= 232) { var c = (args - 232) * 10 + 8; return [c, c, c]; } args -= 16; var rem; var r = Math.floor(args / 36) / 5 * 255; var g = Math.floor((rem = args % 36) / 6) / 5 * 255; var b = rem % 6 / 5 * 255; return [r, g, b]; }; convert.rgb.hex = function (args) { var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF); var string = integer.toString(16).toUpperCase(); return '000000'.substring(string.length) + string; }; convert.hex.rgb = function (args) { var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); if (!match) { return [0, 0, 0]; } var colorString = match[0]; if (match[0].length === 3) { colorString = colorString.split('').map(function (_char) { return _char + _char; }).join(''); } var integer = parseInt(colorString, 16); var r = integer >> 16 & 0xFF; var g = integer >> 8 & 0xFF; var b = integer & 0xFF; return [r, g, b]; }; convert.rgb.hcg = function (rgb) { var r = rgb[0] / 255; var g = rgb[1] / 255; var b = rgb[2] / 255; var max = Math.max(Math.max(r, g), b); var min = Math.min(Math.min(r, g), b); var chroma = max - min; var grayscale; var hue; if (chroma < 1) { grayscale = min / (1 - chroma); } else { grayscale = 0; } if (chroma <= 0) { hue = 0; } else if (max === r) { hue = (g - b) / chroma % 6; } else if (max === g) { hue = 2 + (b - r) / chroma; } else { hue = 4 + (r - g) / chroma; } hue /= 6; hue %= 1; return [hue * 360, chroma * 100, grayscale * 100]; }; convert.hsl.hcg = function (hsl) { var s = hsl[1] / 100; var l = hsl[2] / 100; var c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l); var f = 0; if (c < 1.0) { f = (l - 0.5 * c) / (1.0 - c); } return [hsl[0], c * 100, f * 100]; }; convert.hsv.hcg = function (hsv) { var s = hsv[1] / 100; var v = hsv[2] / 100; var c = s * v; var f = 0; if (c < 1.0) { f = (v - c) / (1 - c); } return [hsv[0], c * 100, f * 100]; }; convert.hcg.rgb = function (hcg) { var h = hcg[0] / 360; var c = hcg[1] / 100; var g = hcg[2] / 100; if (c === 0.0) { return [g * 255, g * 255, g * 255]; } var pure = [0, 0, 0]; var hi = h % 1 * 6; var v = hi % 1; var w = 1 - v; var mg = 0; /* eslint-disable max-statements-per-line */ switch (Math.floor(hi)) { case 0: pure[0] = 1; pure[1] = v; pure[2] = 0; break; case 1: pure[0] = w; pure[1] = 1; pure[2] = 0; break; case 2: pure[0] = 0; pure[1] = 1; pure[2] = v; break; case 3: pure[0] = 0; pure[1] = w; pure[2] = 1; break; case 4: pure[0] = v; pure[1] = 0; pure[2] = 1; break; default: pure[0] = 1; pure[1] = 0; pure[2] = w; } /* eslint-enable max-statements-per-line */ mg = (1.0 - c) * g; return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255]; }; convert.hcg.hsv = function (hcg) { var c = hcg[1] / 100; var g = hcg[2] / 100; var v = c + g * (1.0 - c); var f = 0; if (v > 0.0) { f = c / v; } return [hcg[0], f * 100, v * 100]; }; convert.hcg.hsl = function (hcg) { var c = hcg[1] / 100; var g = hcg[2] / 100; var l = g * (1.0 - c) + 0.5 * c; var s = 0; if (l > 0.0 && l < 0.5) { s = c / (2 * l); } else if (l >= 0.5 && l < 1.0) { s = c / (2 * (1 - l)); } return [hcg[0], s * 100, l * 100]; }; convert.hcg.hwb = function (hcg) { var c = hcg[1] / 100; var g = hcg[2] / 100; var v = c + g * (1.0 - c); return [hcg[0], (v - c) * 100, (1 - v) * 100]; }; convert.hwb.hcg = function (hwb) { var w = hwb[1] / 100; var b = hwb[2] / 100; var v = 1 - b; var c = v - w; var g = 0; if (c < 1) { g = (v - c) / (1 - c); } return [hwb[0], c * 100, g * 100]; }; convert.apple.rgb = function (apple) { return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255]; }; convert.rgb.apple = function (rgb) { return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535]; }; convert.gray.rgb = function (args) { return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; }; convert.gray.hsl = function (args) { return [0, 0, args[0]]; }; convert.gray.hsv = convert.gray.hsl; convert.gray.hwb = function (gray) { return [0, 100, gray[0]]; }; convert.gray.cmyk = function (gray) { return [0, 0, 0, gray[0]]; }; convert.gray.lab = function (gray) { return [gray[0], 0, 0]; }; convert.gray.hex = function (gray) { var val = Math.round(gray[0] / 100 * 255) & 0xFF; var integer = (val << 16) + (val << 8) + val; var string = integer.toString(16).toUpperCase(); return '000000'.substring(string.length) + string; }; convert.rgb.gray = function (rgb) { var val = (rgb[0] + rgb[1] + rgb[2]) / 3; return [val / 255 * 100]; }; /***/ }), /***/ 907: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } var conversions = __webpack_require__(208); var route = __webpack_require__(171); var convert = {}; var models = Object.keys(conversions); function wrapRaw(fn) { var wrappedFn = function wrappedFn() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var arg0 = args[0]; if (arg0 === undefined || arg0 === null) { return arg0; } if (arg0.length > 1) { args = arg0; } return fn(args); }; // Preserve .conversion property if there is one if ('conversion' in fn) { wrappedFn.conversion = fn.conversion; } return wrappedFn; } function wrapRounded(fn) { var wrappedFn = function wrappedFn() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } var arg0 = args[0]; if (arg0 === undefined || arg0 === null) { return arg0; } if (arg0.length > 1) { args = arg0; } var result = fn(args); // We're assuming the result is an array here. // see notice in conversions.js; don't use box types // in conversion functions. if (_typeof(result) === 'object') { for (var len = result.length, i = 0; i < len; i++) { result[i] = Math.round(result[i]); } } return result; }; // Preserve .conversion property if there is one if ('conversion' in fn) { wrappedFn.conversion = fn.conversion; } return wrappedFn; } models.forEach(function (fromModel) { convert[fromModel] = {}; Object.defineProperty(convert[fromModel], 'channels', { value: conversions[fromModel].channels }); Object.defineProperty(convert[fromModel], 'labels', { value: conversions[fromModel].labels }); var routes = route(fromModel); var routeModels = Object.keys(routes); routeModels.forEach(function (toModel) { var fn = routes[toModel]; convert[fromModel][toModel] = wrapRounded(fn); convert[fromModel][toModel].raw = wrapRaw(fn); }); }); module.exports = convert; /***/ }), /***/ 171: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var conversions = __webpack_require__(208); /* This function routes a model to all other models. all functions that are routed have a property `.conversion` attached to the returned synthetic function. This property is an array of strings, each with the steps in between the 'from' and 'to' color models (inclusive). conversions that are not possible simply are not included. */ function buildGraph() { var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3 var models = Object.keys(conversions); for (var len = models.length, i = 0; i < len; i++) { graph[models[i]] = { // http://jsperf.com/1-vs-infinity // micro-opt, but this is simple. distance: -1, parent: null }; } return graph; } // https://en.wikipedia.org/wiki/Breadth-first_search function deriveBFS(fromModel) { var graph = buildGraph(); var queue = [fromModel]; // Unshift -> queue -> pop graph[fromModel].distance = 0; while (queue.length) { var current = queue.pop(); var adjacents = Object.keys(conversions[current]); for (var len = adjacents.length, i = 0; i < len; i++) { var adjacent = adjacents[i]; var node = graph[adjacent]; if (node.distance === -1) { node.distance = graph[current].distance + 1; node.parent = current; queue.unshift(adjacent); } } } return graph; } function link(from, to) { return function (args) { return to(from(args)); }; } function wrapConversion(toModel, graph) { var path = [graph[toModel].parent, toModel]; var fn = conversions[graph[toModel].parent][toModel]; var cur = graph[toModel].parent; while (graph[cur].parent) { path.unshift(graph[cur].parent); fn = link(conversions[graph[cur].parent][cur], fn); cur = graph[cur].parent; } fn.conversion = path; return fn; } module.exports = function (fromModel) { var graph = deriveBFS(fromModel); var conversion = {}; var models = Object.keys(graph); for (var len = models.length, i = 0; i < len; i++) { var toModel = models[i]; var node = graph[toModel]; if (node.parent === null) { // No possible conversion, or this node is the source model. continue; } conversion[toModel] = wrapConversion(toModel, graph); } return conversion; }; /***/ }), /***/ 101: /***/ (function(module) { "use strict"; module.exports = { "aliceblue": [240, 248, 255], "antiquewhite": [250, 235, 215], "aqua": [0, 255, 255], "aquamarine": [127, 255, 212], "azure": [240, 255, 255], "beige": [245, 245, 220], "bisque": [255, 228, 196], "black": [0, 0, 0], "blanchedalmond": [255, 235, 205], "blue": [0, 0, 255], "blueviolet": [138, 43, 226], "brown": [165, 42, 42], "burlywood": [222, 184, 135], "cadetblue": [95, 158, 160], "chartreuse": [127, 255, 0], "chocolate": [210, 105, 30], "coral": [255, 127, 80], "cornflowerblue": [100, 149, 237], "cornsilk": [255, 248, 220], "crimson": [220, 20, 60], "cyan": [0, 255, 255], "darkblue": [0, 0, 139], "darkcyan": [0, 139, 139], "darkgoldenrod": [184, 134, 11], "darkgray": [169, 169, 169], "darkgreen": [0, 100, 0], "darkgrey": [169, 169, 169], "darkkhaki": [189, 183, 107], "darkmagenta": [139, 0, 139], "darkolivegreen": [85, 107, 47], "darkorange": [255, 140, 0], "darkorchid": [153, 50, 204], "darkred": [139, 0, 0], "darksalmon": [233, 150, 122], "darkseagreen": [143, 188, 143], "darkslateblue": [72, 61, 139], "darkslategray": [47, 79, 79], "darkslategrey": [47, 79, 79], "darkturquoise": [0, 206, 209], "darkviolet": [148, 0, 211], "deeppink": [255, 20, 147], "deepskyblue": [0, 191, 255], "dimgray": [105, 105, 105], "dimgrey": [105, 105, 105], "dodgerblue": [30, 144, 255], "firebrick": [178, 34, 34], "floralwhite": [255, 250, 240], "forestgreen": [34, 139, 34], "fuchsia": [255, 0, 255], "gainsboro": [220, 220, 220], "ghostwhite": [248, 248, 255], "gold": [255, 215, 0], "goldenrod": [218, 165, 32], "gray": [128, 128, 128], "green": [0, 128, 0], "greenyellow": [173, 255, 47], "grey": [128, 128, 128], "honeydew": [240, 255, 240], "hotpink": [255, 105, 180], "indianred": [205, 92, 92], "indigo": [75, 0, 130], "ivory": [255, 255, 240], "khaki": [240, 230, 140], "lavender": [230, 230, 250], "lavenderblush": [255, 240, 245], "lawngreen": [124, 252, 0], "lemonchiffon": [255, 250, 205], "lightblue": [173, 216, 230], "lightcoral": [240, 128, 128], "lightcyan": [224, 255, 255], "lightgoldenrodyellow": [250, 250, 210], "lightgray": [211, 211, 211], "lightgreen": [144, 238, 144], "lightgrey": [211, 211, 211], "lightpink": [255, 182, 193], "lightsalmon": [255, 160, 122], "lightseagreen": [32, 178, 170], "lightskyblue": [135, 206, 250], "lightslategray": [119, 136, 153], "lightslategrey": [119, 136, 153], "lightsteelblue": [176, 196, 222], "lightyellow": [255, 255, 224], "lime": [0, 255, 0], "limegreen": [50, 205, 50], "linen": [250, 240, 230], "magenta": [255, 0, 255], "maroon": [128, 0, 0], "mediumaquamarine": [102, 205, 170], "mediumblue": [0, 0, 205], "mediumorchid": [186, 85, 211], "mediumpurple": [147, 112, 219], "mediumseagreen": [60, 179, 113], "mediumslateblue": [123, 104, 238], "mediumspringgreen": [0, 250, 154], "mediumturquoise": [72, 209, 204], "mediumvioletred": [199, 21, 133], "midnightblue": [25, 25, 112], "mintcream": [245, 255, 250], "mistyrose": [255, 228, 225], "moccasin": [255, 228, 181], "navajowhite": [255, 222, 173], "navy": [0, 0, 128], "oldlace": [253, 245, 230], "olive": [128, 128, 0], "olivedrab": [107, 142, 35], "orange": [255, 165, 0], "orangered": [255, 69, 0], "orchid": [218, 112, 214], "palegoldenrod": [238, 232, 170], "palegreen": [152, 251, 152], "paleturquoise": [175, 238, 238], "palevioletred": [219, 112, 147], "papayawhip": [255, 239, 213], "peachpuff": [255, 218, 185], "peru": [205, 133, 63], "pink": [255, 192, 203], "plum": [221, 160, 221], "powderblue": [176, 224, 230], "purple": [128, 0, 128], "rebeccapurple": [102, 51, 153], "red": [255, 0, 0], "rosybrown": [188, 143, 143], "royalblue": [65, 105, 225], "saddlebrown": [139, 69, 19], "salmon": [250, 128, 114], "sandybrown": [244, 164, 96], "seagreen": [46, 139, 87], "seashell": [255, 245, 238], "sienna": [160, 82, 45], "silver": [192, 192, 192], "skyblue": [135, 206, 235], "slateblue": [106, 90, 205], "slategray": [112, 128, 144], "slategrey": [112, 128, 144], "snow": [255, 250, 250], "springgreen": [0, 255, 127], "steelblue": [70, 130, 180], "tan": [210, 180, 140], "teal": [0, 128, 128], "thistle": [216, 191, 216], "tomato": [255, 99, 71], "turquoise": [64, 224, 208], "violet": [238, 130, 238], "wheat": [245, 222, 179], "white": [255, 255, 255], "whitesmoke": [245, 245, 245], "yellow": [255, 255, 0], "yellowgreen": [154, 205, 50] }; /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ /******/ !function() { /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function() { return module['default']; } : /******/ function() { return module; }; /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; /******/ }(); /******/ /******/ /* webpack/runtime/define property getters */ /******/ !function() { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = function(exports, definition) { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ }(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ !function() { /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } /******/ }(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ !function() { /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ }(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be in strict mode. !function() { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "CssColorParser": function() { return /* reexport */ src_CssColorParser; }, "CssColorParserPlus": function() { return /* reexport */ src_CssColorParserPlus; } }); ;// CONCATENATED MODULE: ./src/utils/common.ts var Check = /** @class */ (function () { function Check() { } Check.type = function (paramName, value, type) { var valueType = typeof value; if (valueType !== type) { throw new Error("Expected ".concat(paramName, " to be typeof ").concat(type, ", actual typeof was ").concat(valueType)); } }; Check.types = function (paramName, value, types) { var valueType = typeof value; var isContained = types.includes(valueType); if (!isContained) { throw new Error("Expected ".concat(paramName, " to be typeof ").concat(types.join('|'), ", actual typeof was ").concat(valueType)); } }; Check.numValue = function (paramName, value, min, max) { Check.numMinValue(paramName, value, min); Check.numMaxValue(paramName, value, max); }; Check.numMinValue = function (paramName, value, min) { if (value < min) { throw new Error("Expected ".concat(paramName, " to > ").concat(min, ", actual value was ").concat(value)); } }; Check.numMaxValue = function (paramName, value, max) { if (value > max) { throw new Error("Expected ".concat(paramName, " to < ").concat(max, ", actual value was ").concat(value)); } }; Check.numIsInt = function (paramName, value, expectIsInt) { var isInt = Math.floor(value) === value; if (isInt !== expectIsInt) { throw new Error("Expected ".concat(paramName, " to ").concat(expectIsInt ? 'Integer' : 'Float', ", actual value was ").concat(isInt ? 'Integer' : 'Float')); } }; return Check; }()); var ColorJson = /** @class */ (function () { function ColorJson() { } return ColorJson; }()); function defaultValue(v, defaultV) { if (v === undefined || v === null) { return defaultV; } if (isNaN(v) && typeof defaultV === 'number') { return defaultV; } return v; } function limitNumber(min, max, v) { if (v > max) { v = max; } else if (v < min) { v = min; } return v; } function setNumberPrecision(number, precision) { if (number === void 0) { number = 0; } var prec = Math.pow(10, precision); return Math.round(number * prec) / prec; } ;// CONCATENATED MODULE: ./src/utils/color-tools.ts /* * @Author: roman_123 * @Description: 部分核心代码修改自cesium * @Date: 2022-11-28 17:32:57 * @LastEditTime: 2022-12-06 00:02:21 */ var CssColorStringParser = /** @class */ (function () { function CssColorStringParser() { } // 去除字符串内所有空格 CssColorStringParser.clearStrSpace = function (v) { return v.replace(/\s/g, ''); }; // 去除字符串两边空格,将中间多个空格合并为一个 CssColorStringParser.trimStr = function (v) { v = v.replace(/\s+/g, ' '); return v.trim(); }; // 解析3位16进制 #fff #fff0 CssColorStringParser.parse3BitsHEX = function (v) { var regx = /^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i; var res = regx.exec(v); if (res) { var res4 = defaultValue(res[4], 'f'); var r = CssColorStringParser._parseResStrForRgb(parseInt(res[1] + res[1], 16)); var g = CssColorStringParser._parseResStrForRgb(parseInt(res[2] + res[2], 16)); var b = CssColorStringParser._parseResStrForRgb(parseInt(res[3] + res[3], 16)); var a = CssColorStringParser._parsePercent(parseInt(res4 + res4, 16) / 255); return [r, g, b, a]; } return null; }; // 解析6位16进制 #ffffff #ffffff00 CssColorStringParser.parse6BitsHEX = function (v) { var regx = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i; var res = regx.exec(v); if (res) { var res4 = defaultValue(res[4], 'ff'); var r = CssColorStringParser._parseResStrForRgb(parseInt(res[1], 16)); var g = CssColorStringParser._parseResStrForRgb(parseInt(res[2], 16)); var b = CssColorStringParser._parseResStrForRgb(parseInt(res[3], 16)); var a = CssColorStringParser._parsePercent(parseInt(res4, 16) / 255.0); return [r, g, b, a]; } return null; }; // 解析rgb rgba rgb(255,255,255) rgba(255,255,255,1) rgba(100%,100%,100%, 1) CssColorStringParser.parseRGBA = function (v) { var regx = /^rgba?\(([0-9.]+%?),([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i; var res = regx.exec(v); if (res) { var r = CssColorStringParser._parseResStrForRgb(res[1]); var g = CssColorStringParser._parseResStrForRgb(res[2]); var b = CssColorStringParser._parseResStrForRgb(res[3]); var a = CssColorStringParser._parsePercent(res[4]); return [r, g, b, a]; } return null; }; // 解析hsl hsla hsl(360,100%,100%) hsla(360,100%,100%,1) CssColorStringParser.parseHSLA = function (v) { var regx = /^hsla?\(([0-9.]+)(?:deg)?,([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i; var res = regx.exec(v); if (res) { var h = CssColorStringParser._parseResStrForHue(res[1]); var s = CssColorStringParser._parsePercent(res[2]); var l = CssColorStringParser._parsePercent(res[3]); var a = CssColorStringParser._parsePercent(res[4]); return [h, s, l, a]; } return null; }; // 解析hwb CssColorStringParser.parseHWB = function (v) { var regx = /^hwb\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i; var res = regx.exec(v); if (res) { var h = CssColorStringParser._parseResStrForHue(res[1]); var w = CssColorStringParser._parsePercent(res[2]); var b = CssColorStringParser._parsePercent(res[3]); var a = CssColorStringParser._parsePercent(res[4]); return [h, w, b, a]; } return null; }; // 解析rgb rgb(178 57 57 / 44%) 字符串中存在空格,因此使用清除两侧空格的原始字符串 CssColorStringParser.parseRGBA2 = function (v) { var regx = /^rgba?\s?\(\s?([0-9.]+%?)\s?([0-9.]+%?)\s?([0-9.]+%?)(?:\s?\/\s?([0-9.]+%?))?\s?\)$/i; var res = regx.exec(v); if (res) { var r = CssColorStringParser._parseResStrForRgb(res[1]); var g = CssColorStringParser._parseResStrForRgb(res[2]); var b = CssColorStringParser._parseResStrForRgb(res[3]); var a = CssColorStringParser._parsePercent(res[4]); return [r, g, b, a]; } return null; }; // 解析hsl hsl(215 85% 62% / 1) CssColorStringParser.parseHSLA2 = function (v) { var regx = /^hsla?\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i; var res = regx.exec(v); if (res) { var h = CssColorStringParser._parseResStrForHue(res[1]); var s = CssColorStringParser._parsePercent(res[2]); var l = CssColorStringParser._parsePercent(res[3]); var a = CssColorStringParser._parsePercent(res[4]); return [h, s, l, a]; } return null; }; // 将结果解析为数字 CssColorStringParser._parseResStrForRgb = function (v) { if (typeof v === 'string') { v = parseFloat(v) / ('%' === v.substr(-1) ? 100.0 / 255 : 1); } if (isNaN(v)) { v = 1; } return limitNumber(0, 255, v); }; CssColorStringParser._parseResStrForHue = function (v) { if (typeof v === 'string') { v = parseFloat(v); } if (isNaN(v)) { v = 0; } return limitNumber(0, 360, v); }; CssColorStringParser._parsePercent = function (v) { if (typeof v === 'string') { v = parseFloat(v) / ('%' === v.substr(-1) ? 100.0 : 1); } if (isNaN(v)) { v = 1; } return limitNumber(0, 1, v); }; return CssColorStringParser; }()); ;// CONCATENATED MODULE: ./src/CssColorParser.ts /* * @Descripttion: 颜色解析器(轻量) * @version: 1.0.0 * @Author: roman_123 * @Date: 2021-01-19 09:22:11 * @LastEditors: Please set LastEditors * @LastEditTime: 2023-06-27 19:01:50 */ var CssColorParser = /** @class */ (function () { function CssColorParser(red, green, blue, alpha) { this.r = 255; this.g = 255; this.b = 255; this.a = 1; this._outColorPrecision = 2; this._outAlphaPrecision = 2; this.setColor(red, green, blue, alpha); } /** * @description: 设置CssColorParser实例输出的精度 * @param {number} colorPrecision 输出颜色的精度 * @param {number} outAlphaPrecision 输出透明度的精度 * @return {CssColorParser} */ CssColorParser.prototype.setOutPrecision = function (colorPrecision, outAlphaPrecision) { Check.type('colorPrecision', colorPrecision, 'number'); Check.type('outAlphaPrecision', outAlphaPrecision, 'number'); Check.numMinValue('colorPrecision', colorPrecision, 0); Check.numMinValue('outAlphaPrecision', outAlphaPrecision, 0); Check.numIsInt('colorPrecision', colorPrecision, true); Check.numIsInt('outAlphaPrecision', outAlphaPrecision, true); this._outColorPrecision = colorPrecision; this._outAlphaPrecision = outAlphaPrecision; return this; }; /** * 设置颜色 * @param red * @param green * @param blue * @param alpha * @example: this.setColor(255,255,255,1) */ CssColorParser.prototype.setColor = function (red, green, blue, alpha) { this.r = limitNumber(0, 255, defaultValue(Number(red), 0)); this.g = limitNumber(0, 255, defaultValue(Number(green), 0)); this.b = limitNumber(0, 255, defaultValue(Number(blue), 0)); this.a = limitNumber(0, 1, defaultValue(Number(alpha), 1)); return this; }; /** * @description: 设置透明度 * @param {number} alpha * @return {CssColorParser} */ CssColorParser.prototype.setAlpha = function (alpha) { this.a = limitNumber(0, 1, defaultValue(Number(alpha), 1)); return this; }; /** * @description: 设置红色值 * @param {number} red * @return {CssColorParser} */ CssColorParser.prototype.setRed = function (red) { this.r = limitNumber(0, 255, defaultValue(Number(red), 0)); return this; }; /** * @description: 设置绿色值 * @param {number} green * @return {CssColorParser} */ CssColorParser.prototype.setGreen = function (green) { this.g = limitNumber(0, 255, defaultValue(Number(green), 0)); return this; }; /** * @description: 设置蓝色值 * @param {number} blue * @return {CssColorParser} */ CssColorParser.prototype.setBlue = function (blue) { this.b = limitNumber(0, 255, defaultValue(Number(blue), 0)); return this; }; /** * @description: 返回rgba格式的css字符串 * @return {string} */ CssColorParser.prototype.toRGBA = function () { var color = this.toJson(); if (color.a === 1) { return "rgb(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ")"); } return "rgba(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ",").concat(color.a, ")"); }; /** * @description: 返回字符串 * @return {string} */ CssColorParser.prototype.toString = function () { return this.toRGBA(); }; /** * @description: 归一化 * @return {array} */ CssColorParser.prototype.toNormalize = function () { var r = setNumberPrecision(this.r / 255, this._outColorPrecision); var g = setNumberPrecision(this.g / 255, this._outColorPrecision); var b = setNumberPrecision(this.b / 255, this._outColorPrecision); var a = setNumberPrecision(this.a, this._outAlphaPrecision); return [r, g, b, a]; }; /** * @description: 返回16进制格式的css字符串 * @return {string} */ CssColorParser.prototype.toHEX = function () { var color = this.toJson(); var r = color.r.toString(16); if (r.length < 2) { r = "0".concat(r); } var g = color.g.toString(16); if (g.length < 2) { g = "0".concat(g); } var b = color.b.toString(16); if (b.length < 2) { b = "0".concat(b); } // 由于tojson后a会丢失精度,此处使用this.a if (this.a < 1) { var hexAlpha = parseInt((this.a * 255).toFixed()).toString(16); if (hexAlpha.length < 2) { hexAlpha = "0".concat(hexAlpha); } return "#".concat(r).concat(g).concat(b).concat(hexAlpha); } return "#".concat(r).concat(g).concat(b); }; /** * @description: 返回rgba数组 * @return {array} */ CssColorParser.prototype.toArray = function () { var color = this.toJson(); return [color.r, color.g, color.b, color.a]; }; /** * @description: 返回ColorJson * @return {ColorJson} */ CssColorParser.prototype.toJson = function () { return { r: setNumberPrecision(this.r, this._outColorPrecision), g: setNumberPrecision(this.g, this._outColorPrecision), b: setNumberPrecision(this.b, this._outColorPrecision), a: setNumberPrecision(this.a, this._outAlphaPrecision), }; }; /** * @description: 返回取反色后的新的实例 * @return {CssColorParser} */ CssColorParser.prototype.toInvert = function () { var r = 255 - this.r; var g = 255 - this.g; var b = 255 - this.b; var a = 1 - this.a; return new CssColorParser(r, g, b, a); }; /** * @description: 拷贝 * @return {CssColorParser} */ CssColorParser.prototype.clone = function () { return new CssColorParser(this.r, this.g, this.b, this.a); }; /** * @description: 比较两个解析对象的数据是否相等 * @param {string} color * @return {boolean} */ CssColorParser.prototype.equals = function (color) { if (this === color) { return true; } else { var json1 = this.toJson(); var json2 = color.toJson(); return (json1.r === json2.r && json1.g === json2.g && json1.b === json2.g && json1.a === json2.a); } }; /** * @description: 反色 * @return {CssColorParser} */ CssColorParser.prototype.setInvert = function () { this.r = 255 - this.r; this.g = 255 - this.g; this.b = 255 - this.b; this.a = 1 - this.a; return this; }; /** * @description: 乘以倍数 * @param {number} scalar * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParser.prototype.multiplyByScalar = function (scalar, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var r = this.r * scalar; var g = this.g * scalar; var b = this.b * scalar; var a = isSetAlpha ? this.a * scalar : this.a; return this.setColor(r, g, b, a); }; /** * @description: 除以倍数 * @param {number} scalar * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParser.prototype.divideByScalar = function (scalar, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var r = this.r / scalar; var g = this.g / scalar; var b = this.b / scalar; var a = isSetAlpha ? this.a / scalar : this.a; return this.setColor(r, g, b, a); }; /** * @description: 实例相加 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParser.prototype.add = function (colorParser, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var r = this.r + colorParser.r; var g = this.g + colorParser.g; var b = this.b + colorParser.b; var a = isSetAlpha ? this.a + colorParser.a : this.a; return this.setColor(r, g, b, a); }; /** * @description: 实例相减 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParser.prototype.subtract = function (colorParser, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var r = this.r - colorParser.r; var g = this.g - colorParser.g; var b = this.b - colorParser.b; var a = isSetAlpha ? this.a - colorParser.a : this.a; return this.setColor(r, g, b, a); }; /** * @description: 实例相乘 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParser.prototype.multiply = function (colorParser, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var r = this.r * colorParser.r; var g = this.g * colorParser.g; var b = this.b * colorParser.b; var a = isSetAlpha ? this.a * colorParser.a : this.a; return this.setColor(r, g, b, a); }; /** * @description: 实例相除 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParser.prototype.divide = function (colorParser, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var r = this.r / colorParser.r; var g = this.g / colorParser.g; var b = this.b / colorParser.b; var a = isSetAlpha ? this.a / colorParser.a : this.a; return this.setColor(r, g, b, a); }; /** * @description: 颜色RGB加上数字 * @param {number} num * @return {CssColorParser} */ CssColorParser.prototype.addNumberForRGB = function (num) { this.r = this.r + num; this.g = this.g + num; this.b = this.b + num; return this; }; /** * @description: 透明度加上数字 * @param {number} num * @return {CssColorParser} */ CssColorParser.prototype.addNumberForAlpha = function (num) { this.a = this.a + num; return this; }; /** * @description: 解析16进制颜色 * @param {string} v * @return {CssColorParser} * @example: CssColorParser.parseHEX('#FFF') */ CssColorParser.parseHEX = function (v) { var cssStr = CssColorStringParser.clearStrSpace(v); var res = CssColorStringParser.parse3BitsHEX(cssStr); if (!res) { res = CssColorStringParser.parse6BitsHEX(cssStr); } return res && CssColorParser.fromArray(res); }; /** * @description: 解析rgba、rgb颜色 * @param {string} v * @return {CssColorParser} * @example: CssColorParser.parseRGBA('rgba(255,255,255,1)') */ CssColorParser.parseRGBA = function (v) { var cssStr = CssColorStringParser.clearStrSpace(v); var res = CssColorStringParser.parseRGBA(cssStr); if (!res) { var cssStr2 = CssColorStringParser.trimStr(v); res = CssColorStringParser.parseRGBA2(cssStr2); } return res && CssColorParser.fromArray(res); }; /** * @description: 将ColorJson格式的json数据转换为解析对象 * @param {ColorJson} json * @return {CssColorParser} * @example: CssColorParser.fromJson({r: 255, g: 255, b: 255, a: 1}) */ CssColorParser.fromJson = function (json) { return new CssColorParser(json.r, json.g, json.b, json.a); }; /** * @description: 将RGBA数组转换为解析对象 * @param {Array} color * @return {CssColorParser} * @example: CssColorParser.fromArray([255,255,255,1]) */ CssColorParser.fromArray = function (color) { return new CssColorParser(color[0], color[1], color[2], color[3]); }; /** * @description: 产生随机颜色 * @return {CssColorParser} * @example: CssColorParser.fromRandom(new CssColorParser(0,0,0,0), new CssColorParser(255,255,255,1)) */ CssColorParser.fromRandom = function (color1, color2) { var r = Math.random() * Math.abs(color2.r - color1.r) + Math.min(color1.r, color2.r); var g = Math.random() * Math.abs(color2.g - color1.g) + Math.min(color1.g, color2.g); var b = Math.random() * Math.abs(color2.b - color1.b) + Math.min(color1.b, color2.b); var a = Math.random() * Math.abs(color2.a - color1.a) + Math.min(color1.a, color2.a); return new CssColorParser(r, g, b, a); }; /** * @description: 颜色序列化数组转换为CssColorParser对象实例 * @param {array} colorArr * @example: CssColorParser.fromNormaliz([1, 0, 0, 1]) */ CssColorParser.fromNormalize = function (colorArr) { var r = colorArr[0] * 255; var g = colorArr[1] * 255; var b = colorArr[2] * 255; var a = colorArr[3]; return CssColorParser.fromArray([r, g, b, a]); }; return CssColorParser; }()); /* harmony default export */ var src_CssColorParser = (CssColorParser); ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var _extendStatics = function extendStatics(d, b) { _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; } || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return _extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); _extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var _assign = function __assign() { _assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return _assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); }; } function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i = decorators.length - 1; i >= 0; i--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || _typeof(result) !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_);else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; } ; function __runInitializers(thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i = 0; i < initializers.length; i++) { value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); } return useValue ? value : void 0; } ; function __propKey(x) { return _typeof(x) === "symbol" ? x : "".concat(x); } ; function __setFunctionName(f, name, prefix) { if (_typeof(name) === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); } ; function __metadata(metadataKey, metadataValue) { if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function sent() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function get() { return m[k]; } }; } Object.defineProperty(o, k2, desc); } : function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }; function __exportStar(m, o) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function next() { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } /** @deprecated */ function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } /** @deprecated */ function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; } ; var __setModuleDefault = Object.create ? function (o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function (o, v) { o["default"] = v; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return mod && mod.__esModule ? mod : { "default": mod }; } function __classPrivateFieldGet(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); } function __classPrivateFieldSet(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; } function __classPrivateFieldIn(state, receiver) { if (receiver === null || _typeof(receiver) !== "object" && typeof receiver !== "function") throw new TypeError("Cannot use 'in' operator on non-object"); return typeof state === "function" ? receiver === state : state.has(receiver); } /* harmony default export */ var tslib_es6 = ({ __extends: __extends, __assign: _assign, __rest: __rest, __decorate: __decorate, __param: __param, __metadata: __metadata, __awaiter: __awaiter, __generator: __generator, __createBinding: __createBinding, __exportStar: __exportStar, __values: __values, __read: __read, __spread: __spread, __spreadArrays: __spreadArrays, __spreadArray: __spreadArray, __await: __await, __asyncGenerator: __asyncGenerator, __asyncDelegator: __asyncDelegator, __asyncValues: __asyncValues, __makeTemplateObject: __makeTemplateObject, __importStar: __importStar, __importDefault: __importDefault, __classPrivateFieldGet: __classPrivateFieldGet, __classPrivateFieldSet: __classPrivateFieldSet, __classPrivateFieldIn: __classPrivateFieldIn }); // EXTERNAL MODULE: ./node_modules/color-convert/index.js var color_convert = __webpack_require__(907); var color_convert_default = /*#__PURE__*/__webpack_require__.n(color_convert); ;// CONCATENATED MODULE: ./src/CssColorParserPlus.ts /* * @Descripttion: 颜色解析器(增强) * @version: 1.0.0 * @Author: roman_123 * @Date: 2021-01-19 09:22:11 * @LastEditors: Please set LastEditors * @LastEditTime: 2023-06-27 18:53:31 */ var CssColorParserPlus = /** @class */ (function (_super) { __extends(CssColorParserPlus, _super); function CssColorParserPlus() { return _super !== null && _super.apply(this, arguments) || this; } /** * @description: 返回取反色后的新的实例 * @return {CssColorParserPlus} */ CssColorParserPlus.prototype.toInvert = function () { var r = 255 - this.r; var g = 255 - this.g; var b = 255 - this.b; var a = 1 - this.a; return new CssColorParserPlus(r, g, b, a); }; /** * @description: 拷贝 * @return {CssColorParserPlus} */ CssColorParserPlus.prototype.clone = function () { return new CssColorParserPlus(this.r, this.g, this.b, this.a); }; /** * @description: 比较两个解析对象的数据是否相等 * @param {string} color * @return {boolean} */ CssColorParserPlus.prototype.equals = function (color) { color = CssColorParserPlus.parseColor(color); if (this === color) { return true; } else { var json1 = this.toJson(); var json2 = color.toJson(); return (json1.r === json2.r && json1.g === json2.g && json1.b === json2.g && json1.a === json2.a); } }; /** * @description: 实例相加 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParserPlus.prototype.add = function (color, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var colorParser = CssColorParserPlus.parseColor(color); return _super.prototype.add.call(this, colorParser, isSetAlpha); }; /** * @description: 实例相减 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParserPlus.prototype.subtract = function (color, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var colorParser = CssColorParserPlus.parseColor(color); return _super.prototype.subtract.call(this, colorParser, isSetAlpha); }; /** * @description: 实例相乘 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParserPlus.prototype.multiply = function (color, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var colorParser = CssColorParserPlus.parseColor(color); return _super.prototype.multiply.call(this, colorParser, isSetAlpha); }; /** * @description: 实例相除 * @param {CssColorParser} colorParser * @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是) * @return {CssColorParser} */ CssColorParserPlus.prototype.divide = function (color, isSetAlpha) { if (isSetAlpha === void 0) { isSetAlpha = true; } var colorParser = CssColorParserPlus.parseColor(color); return _super.prototype.divide.call(this, colorParser, isSetAlpha); }; /** * @description: 解析css颜色 * @param {string} v * @return {CssColorParserPlus} * @example: parseCssColorStr('rgba(255,255,255,1)') */ CssColorParserPlus.parseColor = function (v) { if (v instanceof src_CssColorParser) { return v; } return CssColorParserPlus.parseCssColorStr(v); }; /** * @description: 将css字符串转换为解析对象 * @param {string} v * @return {CssColorParserPlus} * @example: parseCssColorStr('rgba(255,255,255,1)') */ CssColorParserPlus.parseCssColorStr = function (v) { Check.type('color', v, 'string'); return (CssColorParserPlus.parseHEX(v) || CssColorParserPlus.parseRGBA(v) || CssColorParserPlus.parseKeyWord(v) || CssColorParserPlus.parseHSLA(v) || CssColorParserPlus.parseHWB(v)); }; /** * @description: 解析颜色关键字 * @param {string} v * @return {CssColorParserPlus} * @example: parseKeyWord('red') */ CssColorParserPlus.parseKeyWord = function (v) { var cssStr = CssColorStringParser.clearStrSpace(v); var res = color_convert_default().keyword.rgb(cssStr); return res && CssColorParserPlus.fromArray(res); }; /** * @description: 解析HSLA * @param {string} v * @return {CssColorParserPlus} * @example: parseHSLA('hsla(215,85%,62%,0.8)') */ CssColorParserPlus.parseHSLA = function (v) { var cssStr = CssColorStringParser.clearStrSpace(v); var res = CssColorStringParser.parseHSLA(cssStr); if (!res) { var cssStr2 = CssColorStringParser.trimStr(v); res = CssColorStringParser.parseHSLA2(cssStr2); } return res && CssColorParserPlus.fromHSL(res[0], res[1], res[2], res[3]); }; /** * @description: 解析HWB * @param {string} v * @return {CssColorParserPlus} * @example: parseHWB('hwb(215deg 30% 6% / 80%)') */ CssColorParserPlus.parseHWB = function (v) { var cssStr2 = CssColorStringParser.trimStr(v); var res = CssColorStringParser.parseHWB(cssStr2); return res && CssColorParserPlus.fromHWB(res[0], res[1], res[2], res[3]); }; /** * @description: 将HSL色彩模式转换为解析对象 * @param {number} hue 色相 * @param {number} saturation 饱和度 * @param {number} lightness 亮度 * @param {number} alpha 不透明度 * @return {CssColorParserPlus} * @example: fromHSL(0,1,1,1) */ CssColorParserPlus.fromHSL = function (h, s, l, a) { var res = color_convert_default().hsl.rgb(limitNumber(0, 360, h), limitNumber(0, 100, s * 100), limitNumber(0, 100, l * 100)); return new CssColorParserPlus(res[0], res[1], res[2], defaultValue(Number(a), 1)); }; /** * @description: 将HWB色彩模式转换为解析对象 * @param {number} h 色调 * @param {number} w 白度 * @param {number} b 黑度 * @param {number} a 不透明度 * @return {CssColorParserPlus} * @example: fromHSL(0,1,1,1) */ CssColorParserPlus.fromHWB = function (h, w, b, a) { var res = color_convert_default().hwb.rgb(limitNumber(0, 360, h), limitNumber(0, 100, w * 100), limitNumber(0, 100, b * 100)); return new CssColorParserPlus(res[0], res[1], res[2], defaultValue(Number(a), 1)); }; /** * @description: 解析16进制颜色 * @param {string} v * @return {CssColorParserPlus} * @example: CssColorParserPlus.parseHEX('#FFF') */ CssColorParserPlus.parseHEX = function (v) { var cssStr = CssColorStringParser.clearStrSpace(v); var res = CssColorStringParser.parse3BitsHEX(cssStr); if (!res) { res = CssColorStringParser.parse6BitsHEX(cssStr); } return res && CssColorParserPlus.fromArray(res); }; /** * @description: 解析rgba、rgb颜色 * @param {string} v * @return {CssColorParserPlus} * @example: CssColorParserPlus.parseRGBA('rgba(255,255,255,1)') */ CssColorParserPlus.parseRGBA = function (v) { var cssStr = CssColorStringParser.clearStrSpace(v); var res = CssColorStringParser.parseRGBA(cssStr); if (!res) { var cssStr2 = CssColorStringParser.trimStr(v); res = CssColorStringParser.parseRGBA2(cssStr2); } return res && CssColorParserPlus.fromArray(res); }; /** * @description: 将ColorJson格式的json数据转换为解析对象 * @param {ColorJson} json * @return {CssColorParserPlus} * @example: CssColorParserPlus.fromJson({r: 255, g: 255, b: 255, a: 1}) */ CssColorParserPlus.fromJson = function (json) { return new CssColorParserPlus(json.r, json.g, json.b, json.a); }; /** * @description: 将RGBA数组转换为解析对象 * @param {Array} color * @return {CssColorParserPlus} * @example: CssColorParserPlus.fromArray([255,255,255,1]) */ CssColorParserPlus.fromArray = function (color) { return new CssColorParserPlus(color[0], color[1], color[2], color[3]); }; /** * @description: 产生随机颜色 * @return {CssColorParserPlus} * @example: CssColorParserPlus.fromRandom('black', new CssColorParserPlus(255,255,255,1)) */ CssColorParserPlus.fromRandom = function (color1, color2) { color1 = CssColorParserPlus.parseColor(color1); color2 = CssColorParserPlus.parseColor(color2); var r = Math.random() * Math.abs(color2.r - color1.r) + Math.min(color1.r, color2.r); var g = Math.random() * Math.abs(color2.g - color1.g) + Math.min(color1.g, color2.g); var b = Math.random() * Math.abs(color2.b - color1.b) + Math.min(color1.b, color2.b); var a = Math.random() * Math.abs(color2.a - color1.a) + Math.min(color1.a, color2.a); return new CssColorParserPlus(r, g, b, a); }; /** * @description: 颜色序列化数组转换为CssColorParserPlus对象实例 * @param {array} colorArr * @example: CssColorParserPlus.fromNormaliz([1, 0, 0, 1]) */ CssColorParserPlus.fromNormalize = function (colorArr) { var r = colorArr[0] * 255; var g = colorArr[1] * 255; var b = colorArr[2] * 255; var a = colorArr[3]; return CssColorParserPlus.fromArray([r, g, b, a]); }; return CssColorParserPlus; }(src_CssColorParser)); /* harmony default export */ var src_CssColorParserPlus = (CssColorParserPlus); ;// CONCATENATED MODULE: ./src/main.ts /* * @Author: roman_123 * @Description: * @Date: 2023-05-25 17:45:22 * @LastEditTime: 2023-06-27 18:45:32 */ }(); var __webpack_export_target__ = exports; for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i]; if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true }); /******/ })() ;