@hairy/palette 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hairy/palette
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: update type error
8
+
9
+ ## 0.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: change alpha value error
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Minor Changes
package/index.cjs.js CHANGED
@@ -207,8 +207,8 @@ function changeAlpha(color, alpha) {
207
207
  if (typeof color !== "string") {
208
208
  throw new TypeError("Expected a string as color");
209
209
  }
210
- if (alpha === void 0 || alpha < 0 || alpha > 1) {
211
- throw new TypeError("Expected alpha to be between 0 and 1");
210
+ if (alpha === void 0 || alpha < 0 || alpha > 100) {
211
+ throw new TypeError("Expected alpha to be between 1 and 100");
212
212
  }
213
213
  const rgba = textToRgb(color);
214
214
  rgba.a = alpha;
package/index.cjs.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../index.ts"],
4
- "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 1) {\r\n throw new TypeError('Expected alpha to be between 0 and 1')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,IAAM,UAAU;AAaT,kBAAkB,EAAE,GAAG,GAAG,GAAG,KAAe;AACjD,QAAM,QAAQ,MAAM;AAEpB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAEhB,MAAI,IAAI,OAAO,IAAI,OAAO,IAAI,OAAQ,SAAS,IAAK,KAAM;AACxD,UAAM,IAAI,UAAU,6DAA6D;AAAA,EACnF;AAEA,MAAI,OAAO;AACT,QAAI,OAAQ,MAAK,MAAO,MAAM,IAAM,GAAG,IAAK,KAAK,GAAI,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAAA,EAC5E;AAEA,SAAO,MAAO,KAAK,KAAK,IAAM,KAAK,KAAO,KAAK,IAAK,SAAS,EAAE,EAAE,MAAM,CAAC,IAAI;AAC9E;AAaO,kBAAkB,KAAe;AACtC,MAAI,OAAO,QAAQ,UAAU;AAC3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AI,QAAQ,QAAQ,kBAAkB;AAC1E,QAAM,SAAe;AAAA,IACnB,GAAG,IAAI,QAAQ,GAAG,KAAK;AAAA,IACvB,GAAG,WAAW,QAAQ,GAAG,KAAK;AAAA,IAC9B,GAAG,MAAM,QAAQ,GAAG,KAAK;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ;AAEA,SAAO,SAAS,SAAS,MAAM,CAAC;AAClC;AAQA,aAAa,KAAW,GAAW,SAAkB;AACnD,MAAI;AACJ,MAAI,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK;AAI/B,WAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,EAC1D,OAAO;AAIL,WAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,EAC1D;AACA,MAAI,OAAM;AAAG,YAAO;AAAA,WACX,QAAO;AAAK,YAAO;AAE5B,SAAO;AACT;AAQA,oBAAoB,KAAW,GAAW,SAAkB;AAC1D,MAAI;AACJ,MAAI;AAAS,kBAAa,IAAI,IAAI,iBAAiB;AAAA,WAC1C,MAAM;AAAgB,kBAAa,IAAI,IAAI;AAAA;AAC/C,kBAAa,IAAI,IAAI,kBAAkB;AAE5C,MAAI,cAAa;AAAK,kBAAa;AAEnC,MAAI,WAAW,MAAM,mBAAmB,cAAa;AAAI,kBAAa;AAEtE,MAAI,cAAa;AAAG,kBAAa;AAEjC,SAAO;AACT;AAQA,eAAe,KAAW,GAAW,SAAkB;AACrD,MAAI;AACJ,WAAQ,UAAU,IAAI,IAAI,kBAAkB,IAAI,IAAI,IAAI,kBAAkB;AAE1E,MAAI,SAAQ;AAAK,aAAQ;AAEzB,SAAO;AACT;",
4
+ "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 100) {\r\n throw new TypeError('Expected alpha to be between 1 and 100')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,IAAM,UAAU;AAaT,kBAAkB,EAAE,GAAG,GAAG,GAAG,KAAe;AACjD,QAAM,QAAQ,MAAM;AAEpB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAEhB,MAAI,IAAI,OAAO,IAAI,OAAO,IAAI,OAAQ,SAAS,IAAK,KAAM;AACxD,UAAM,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W,GAAW,SAAkB;AACrD,MAAI;AACJ,WAAQ,UAAU,IAAI,IAAI,kBAAkB,IAAI,IAAI,IAAI,kBAAkB;AAE1E,MAAI,SAAQ;AAAK,aAAQ;AAEzB,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/index.esm.js CHANGED
@@ -173,8 +173,8 @@ function changeAlpha(color, alpha) {
173
173
  if (typeof color !== "string") {
174
174
  throw new TypeError("Expected a string as color");
175
175
  }
176
- if (alpha === void 0 || alpha < 0 || alpha > 1) {
177
- throw new TypeError("Expected alpha to be between 0 and 1");
176
+ if (alpha === void 0 || alpha < 0 || alpha > 100) {
177
+ throw new TypeError("Expected alpha to be between 1 and 100");
178
178
  }
179
179
  const rgba = textToRgb(color);
180
180
  rgba.a = alpha;
package/index.esm.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../index.ts"],
4
- "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 1) {\r\n throw new TypeError('Expected alpha to be between 0 and 1')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
- "mappings": ";AAWA,IAAM,UAAU;AAaT,kBAAkB,EAAE,GAAG,GAAG,GAAG,KAAe;AACjD,QAAM,QAAQ,MAAM;AAEpB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAEhB,MAAI,IAAI,OAAO,IAAI,OAAO,IAAI,OAAQ,SAAS,IAAK,KAAM;AACxD,UAAM,IAAI,UAAU,6DAA6D;AAAA,EACnF;AAEA,MAAI,OAAO;AACT,QAAI,OAAQ,MAAK,MAAO,MAAM,IAAM,GAAG,IAAK,KAAK,GAAI,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAAA,EAC5E;AAEA,SAAO,MAAO,KAAK,KAAK,IAAM,KAAK,KAAO,KAAK,IAAK,SAAS,EAAE,EAAE,MAAM,CAAC,IAAI;AAC9E;AAaO,kBAAkB,KAAe;AACtC,MAAI,OAAO,QAAQ,UAAU;AAC3B,UAAM,IAAI,UAAU,mBAAmB;AAAA,EACzC;AAEA,QAAM,IAAI,QAAQ,MAAM,EAAE;AAE1B,MAAI,IAAI,WAAW,GAAG;AACpB,UAAM,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI;AAAA,EACzD,WAAW,IAAI,WAAW,GAAG;AAC3B,UAAM,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI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D,MAAI;AACJ,MAAI,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK;AAI/B,WAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,EAC1D,OAAO;AAIL,WAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,EAC1D;AACA,MAAI,OAAM;AAAG,YAAO;AAAA,WACX,QAAO;AAAK,YAAO;AAE5B,SAAO;AACT;AAQA,oBAAoB,KAAW,GAAW,SAAkB;AAC1D,MAAI;AACJ,MAAI;AAAS,kBAAa,IAAI,IAAI,iBAAiB;AAAA,WAC1C,MAAM;AAAgB,kBAAa,IAAI,IAAI;AAAA;AAC/C,kBAAa,IAAI,IAAI,kBAAkB;AAE5C,MAAI,cAAa;AAAK,kBAAa;AAEnC,MAAI,WAAW,MAAM,mBAAmB,cAAa;AAAI,kBAAa;AAEtE,MAAI,cAAa;AAAG,kBAAa;AAEjC,SAAO;AACT;AAQA,eAAe,KAAW,GAAW,SAAkB;AACrD,MAAI;AACJ,WAAQ,UAAU,IAAI,IAAI,kBAAkB,IAAI,IAAI,IAAI,kBAAkB;AAE1E,MAAI,SAAQ;AAAK,aAAQ;AAEzB,SAAO;AACT;",
4
+ "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 100) {\r\n throw new TypeError('Expected alpha to be between 1 and 100')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
+ "mappings": ";AAWA,IAAM,UAAU;AAaT,kBAAkB,EAAE,GAAG,GAAG,GAAG,KAAe;AACjD,QAAM,QAAQ,MAAM;AAEpB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAEhB,MAAI,IAAI,OAAO,IAAI,OAAO,IAAI,OAAQ,SAAS,IAAK,KAAM;AACxD,UAAM,IAAI,UAAU,6DAA6D;AAAA,EACnF;AAEA,MAAI,OAAO;AACT,QAAI,OAAQ,MAAK,MAAO,MAAM,IAAM,GAAG,IAAK,KAAK,GAAI,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAAA,EAC5E;AAEA,SAAO,MAAO,KAAK,KAAK,IAAM,KAAK,KAAO,KAAK,IAAK,SAAS,EAAE,EAAE,MAAM,CAAC,IAAI;AAC9E;AAaO,kBAAkB,KAAe;AACtC,MAAI,OAAO,QAAQ,UAAU;AAC3B,UAAM,IAAI,UAAU,mBAAmB;AAAA,EACzC;AAEA,QAAM,IAAI,QAAQ,MAAM,EAAE;AAE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KAAK;AAAA,IACvB,GAAG,WAAW,QAAQ,GAAG,KAAK;AAAA,IAC9B,GAAG,MAAM,QAAQ,GAAG,KAAK;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ;AAEA,SAAO,SAAS,SAAS,MAAM,CAAC;AAClC;AAQA,aAAa,KAAW,GAAW,SAAkB;AACnD,MAAI;AACJ,MAAI,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK;AAI/B,WAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,EAC1D,OAAO;AAIL,WAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,EAC1D;AACA,MAAI,OAAM;AAAG,YAAO;AAAA,WACX,QAAO;AAAK,YAAO;AAE5B,SAAO;AACT;AAQA,oBAAoB,KAAW,GAAW,SAAkB;AAC1D,MAAI;AACJ,MAAI;AAAS,kBAAa,IAAI,IAAI,iBAAiB;AAAA,WAC1C,MAAM;AAAgB,kBAAa,IAAI,IAAI;AAAA;AAC/C,kBAAa,IAAI,IAAI,kBAAkB;AAE5C,MAAI,cAAa;AAAK,kBAAa;AAEnC,MAAI,WAAW,MAAM,mBAAmB,cAAa;AAAI,kBAAa;AAEtE,MAAI,cAAa;AAAG,kBAAa;AAEjC,SAAO;AACT;AAQA,eAAe,KAAW,GAAW,SAAkB;AACrD,MAAI;AACJ,WAAQ,UAAU,IAAI,IAAI,kBAAkB,IAAI,IAAI,IAAI,kBAAkB;AAE1E,MAAI,SAAQ;AAAK,aAAQ;AAEzB,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/index.iife.js CHANGED
@@ -207,8 +207,8 @@ var HairyPalette = (() => {
207
207
  if (typeof color !== "string") {
208
208
  throw new TypeError("Expected a string as color");
209
209
  }
210
- if (alpha === void 0 || alpha < 0 || alpha > 1) {
211
- throw new TypeError("Expected alpha to be between 0 and 1");
210
+ if (alpha === void 0 || alpha < 0 || alpha > 100) {
211
+ throw new TypeError("Expected alpha to be between 1 and 100");
212
212
  }
213
213
  const rgba = textToRgb(color);
214
214
  rgba.a = alpha;
package/index.iife.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../index.ts"],
4
- "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 1) {\r\n throw new TypeError('Expected alpha to be between 0 and 1')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA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M;AAAG,cAAO;AAAA,aACX,QAAO;AAAK,cAAO;AAE5B,WAAO;AAAA,EACT;AAQA,sBAAoB,KAAW,GAAW,SAAkB;AAC1D,QAAI;AACJ,QAAI;AAAS,oBAAa,IAAI,IAAI,iBAAiB;AAAA,aAC1C,MAAM;AAAgB,oBAAa,IAAI,IAAI;AAAA;AAC/C,oBAAa,IAAI,IAAI,kBAAkB;AAE5C,QAAI,cAAa;AAAK,oBAAa;AAEnC,QAAI,WAAW,MAAM,mBAAmB,cAAa;AAAI,oBAAa;AAEtE,QAAI,cAAa;AAAG,oBAAa;AAEjC,WAAO;AAAA,EACT;AAQA,iBAAe,KAAW,GAAW,SAAkB;AACrD,QAAI;AACJ,aAAQ,UAAU,IAAI,IAAI,kBAAkB,IAAI,IAAI,IAAI,kBAAkB;AAE1E,QAAI,SAAQ;AAAK,eAAQ;AAEzB,WAAO;AAAA,EACT;",
4
+ "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 100) {\r\n throw new TypeError('Expected alpha to be between 1 and 100')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,UAAU;AAaT,oBAAkB,EAAE,GAAG,GAAG,GAAG,KAAe;AACjD,UAAM,QAAQ,MAAM;AAEpB,QAAI,KAAK,MAAM,CAAC;AAChB,QAAI,KAAK,MAAM,CAAC;AAChB,QAAI,KAAK,MAAM,CAAC;AAEhB,QAAI,IAAI,OAAO,IAAI,OAAO,IAAI,OAAQ,SAAS,IAAK,KAAM;AACxD,YAAM,IAAI,UAAU,6DAA6D;AAAA,IACnF;AAEA,QAAI,OAAO;AACT,UAAI,OAAQ,MAAK,MAAO,MAAM,IAAM,GAAG,IAAK,KAAK,GAAI,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAAA,IAC5E;AAEA,WAAO,MAAO,KAAK,KAAK,IAAM,KAAK,KAAO,KAAK,IAAK,SAAS,EAAE,EAAE,MAAM,CAAC,IAAI;AAAA,EAC9E;AAaO,oBAAkB,KAAe;AACtC,QAAI,OAAO,QAAQ,UAAU;AAC3B,YAAM,IAAI,UAAU,mBAAmB;AAAA,IACzC;AAEA,UAAM,IAAI,QAAQ,MAAM,EAAE;AAE1B,QAAI,IAAI,WAAW,GAAG;AACpB,YAAM,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK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AAW,QAAQ,GAAG,KAAK;AAAA,MAC9B,GAAG,MAAM,QAAQ,GAAG,KAAK;AAAA,MACzB,GAAG,OAAO;AAAA,IACZ;AAEA,WAAO,SAAS,SAAS,MAAM,CAAC;AAAA,EAClC;AAQA,eAAa,KAAW,GAAW,SAAkB;AACnD,QAAI;AACJ,QAAI,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK;AAI/B,aAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,IAC1D,OAAO;AAIL,aAAM,UAAU,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU;AAAA,IAC1D;AACA,QAAI,OAAM;AAAG,cAAO;AAAA,aACX,QAAO;AAAK,cAAO;AAE5B,WAAO;AAAA,EACT;AAQA,sBAAoB,KAAW,GAAW,SAAkB;AAC1D,QAAI;AACJ,QAAI;AAAS,oBAAa,IAAI,IAAI,iBAAiB;AAAA,aAC1C,MAAM;AAAgB,oBAAa,IAAI,IAAI;AAAA;AAC/C,oBAAa,IAAI,IAAI,kBAAkB;AAE5C,QAAI,cAAa;AAAK,oBAAa;AAEnC,QAAI,WAAW,MAAM,mBAAmB,cAAa;AAAI,oBAAa;AAEtE,QAAI,cAAa;AAAG,oBAAa;AAEjC,WAAO;AAAA,EACT;AAQA,iBAAe,KAAW,GAAW,SAAkB;AACrD,QAAI;AACJ,aAAQ,UAAU,IAAI,IAAI,kBAAkB,IAAI,IAAI,IAAI,kBAAkB;AAE1E,QAAI,SAAQ;AAAK,eAAQ;AAEzB,WAAO;AAAA,EACT;",
6
6
  "names": []
7
7
  }
package/index.iife.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var HairyPalette=(()=>{var y=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)y(t,e,{get:r[e],enumerable:!0})},H=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of A(r))!B.call(t,o)&&o!==e&&y(t,o,{get:()=>r[o],enumerable:!(n=S(r,o))||n.enumerable});return t};var _=t=>H(y({},"__esModule",{value:!0}),t);var J={};G(J,{blend:()=>I,blendAlpha:()=>j,brightness:()=>V,changeAlpha:()=>v,colorPalette:()=>q,hexToRgb:()=>T,hsvToRgb:()=>M,lighten:()=>k,luminosity:()=>L,rgbToHex:()=>g,rgbToHsv:()=>m,textToRgb:()=>u});var X=/^rgb(a)?\((\d{1,3}),(\d{1,3}),(\d{1,3}),?([01]?\.?\d*?)?\)$/;function g({r:t,g:r,b:e,a:n}){let o=n!==void 0;if(t=Math.round(t),r=Math.round(r),e=Math.round(e),t>255||r>255||e>255||o&&n>100)throw new TypeError("Expected 3 numbers below 256 (and optionally one below 100)");return o&&(n=Number((Math.round(255*n/100)|1<<8).toString(16).slice(1))),"#"+(e|r<<8|t<<16|1<<24).toString(16).slice(1)+n}function T(t){if(typeof t!="string")throw new TypeError("Expected a string");t=t.replace(/^#/,""),t.length===3?t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t.length===4&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);let r=parseInt(t,16);return t.length>6?{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:Math.round((r&255)/2.55)}:{r:r>>16,g:r>>8&255,b:r&255}}function M({h:t,s:r,v:e,a:n}){let o,i,a;r=r/100,e=e/100,t=t/360;let p=Math.floor(t*6),b=t*6-p,s=e*(1-r),d=e*(1-b*r),c=e*(1-(1-b)*r);switch(p%6){case 0:o=e,i=c,a=s;break;case 1:o=d,i=e,a=s;break;case 2:o=s,i=e,a=c;break;case 3:o=s,i=d,a=e;break;case 4:o=c,i=s,a=e;break;case 5:o=e,i=s,a=d;break}return{r:Math.round(o*255),g:Math.round(i*255),b:Math.round(a*255),a:n}}function m({r:t,g:r,b:e,a:n}){let o=Math.max(t,r,e),i=Math.min(t,r,e),a=o-i,p=o===0?0:a/o,b=o/255,s;switch(o){case i:s=0;break;case t:s=r-e+a*(r<e?6:0),s/=6*a;break;case r:s=e-t+a*2,s/=6*a;break;case e:s=t-r+a*4,s/=6*a;break}return{h:Math.round(s*360),s:Math.round(p*100),v:Math.round(b*100),a:n||1}}function u(t){if(typeof t!="string")throw new TypeError("Expected a string");let r=t.replace(/ /g,""),e=X.exec(r);if(e===null)return T(r);let n={r:Math.min(255,parseInt(e[2],10)),g:Math.min(255,parseInt(e[3],10)),b:Math.min(255,parseInt(e[4],10))};if(e[1]){let o=parseFloat(e[5]);n.a=Math.min(1,isNaN(o)===!0?1:o)*100}return n}function k(t,r){if(typeof t!="string")throw new TypeError("Expected a string as color");if(typeof r!="number")throw new TypeError("Expected a numeric percent");let e=u(t),n=r<0?0:255,o=Math.abs(r)/100,i=e.r,a=e.g,p=e.b;return"#"+(16777216+(Math.round((n-i)*o)+i)*65536+(Math.round((n-a)*o)+a)*256+(Math.round((n-p)*o)+p)).toString(16).slice(1)}function L(t){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b} object as color");let r=typeof t=="string"?u(t):t,e=r.r/255,n=r.g/255,o=r.b/255,i=e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4),a=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),p=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4);return .2126*i+.7152*a+.0722*p}function V(t){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b} object as color");let r=typeof t=="string"?u(t):t;return(r.r*299+r.g*587+r.b*114)/1e3}function I(t,r){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b[, a]} object as fgColor");if(typeof r!="string"&&(!r||r.r===void 0))throw new TypeError("Expected a string or a {r, g, b[, a]} object as bgColor");let e=typeof t=="string"?u(t):t,n=e.r/255,o=e.g/255,i=e.b/255,a=e.a!==void 0?e.a/100:1,p=typeof r=="string"?u(r):r,b=p.r/255,s=p.g/255,d=p.b/255,c=p.a!==void 0?p.a/100:1,f=a+c*(1-a),l=Math.round((n*a+b*c*(1-a))/f*255),x=Math.round((o*a+s*c*(1-a))/f*255),O=Math.round((i*a+d*c*(1-a))/f*255),w={r:l,g:x,b:O,a:Math.round(f*100)};return typeof t=="string"?g(w):w}function j(t,r){if(typeof t!="string")throw new TypeError("Expected a string as color");if(r===void 0||r<-1||r>1)throw new TypeError("Expected offset to be between -1 and 1");let{r:e,g:n,b:o,a:i}=u(t),a=i!==void 0?i/100:0;return g({r:e,g:n,b:o,a:Math.round(Math.min(1,Math.max(0,a+r))*100)})}function v(t,r){if(typeof t!="string")throw new TypeError("Expected a string as color");if(r===void 0||r<0||r>1)throw new TypeError("Expected alpha to be between 0 and 1");let e=u(t);return e.a=r,g(e)}var E=2,R=16,C=5,N=5,P=15,h=5,D=4;function q(t,r){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b} object as color");let e=typeof t=="string"?u(t):t,n=m(e);if(r===6)return g(e);let o=r<6,i=o?h+1-r:r-h-1,a={h:F(n,i,o),s:$(n,i,o),v:z(n,i,o),a:n.a};return g(M(a))}function F(t,r,e){let n;return t.h>=60&&t.h<=240?n=e?t.h-E*r:t.h+E*r:n=e?t.h+E*r:t.h-E*r,n<0?n+=360:n>=360&&(n-=360),n}function $(t,r,e){let n;return e?n=t.s-R*r:r===D?n=t.s+R:n=t.s+C*r,n>100&&(n=100),e&&r===h&&n>10&&(n=10),n<6&&(n=6),n}function z(t,r,e){let n;return n=e?t.v+N*r:t.v-P*r,n>100&&(n=100),n}return _(J);})();
1
+ var HairyPalette=(()=>{var y=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)y(t,e,{get:r[e],enumerable:!0})},H=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of A(r))!B.call(t,o)&&o!==e&&y(t,o,{get:()=>r[o],enumerable:!(n=S(r,o))||n.enumerable});return t};var _=t=>H(y({},"__esModule",{value:!0}),t);var J={};G(J,{blend:()=>I,blendAlpha:()=>j,brightness:()=>V,changeAlpha:()=>v,colorPalette:()=>q,hexToRgb:()=>T,hsvToRgb:()=>M,lighten:()=>k,luminosity:()=>L,rgbToHex:()=>g,rgbToHsv:()=>m,textToRgb:()=>u});var X=/^rgb(a)?\((\d{1,3}),(\d{1,3}),(\d{1,3}),?([01]?\.?\d*?)?\)$/;function g({r:t,g:r,b:e,a:n}){let o=n!==void 0;if(t=Math.round(t),r=Math.round(r),e=Math.round(e),t>255||r>255||e>255||o&&n>100)throw new TypeError("Expected 3 numbers below 256 (and optionally one below 100)");return o&&(n=Number((Math.round(255*n/100)|1<<8).toString(16).slice(1))),"#"+(e|r<<8|t<<16|1<<24).toString(16).slice(1)+n}function T(t){if(typeof t!="string")throw new TypeError("Expected a string");t=t.replace(/^#/,""),t.length===3?t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t.length===4&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);let r=parseInt(t,16);return t.length>6?{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:Math.round((r&255)/2.55)}:{r:r>>16,g:r>>8&255,b:r&255}}function M({h:t,s:r,v:e,a:n}){let o,i,a;r=r/100,e=e/100,t=t/360;let p=Math.floor(t*6),b=t*6-p,s=e*(1-r),d=e*(1-b*r),c=e*(1-(1-b)*r);switch(p%6){case 0:o=e,i=c,a=s;break;case 1:o=d,i=e,a=s;break;case 2:o=s,i=e,a=c;break;case 3:o=s,i=d,a=e;break;case 4:o=c,i=s,a=e;break;case 5:o=e,i=s,a=d;break}return{r:Math.round(o*255),g:Math.round(i*255),b:Math.round(a*255),a:n}}function m({r:t,g:r,b:e,a:n}){let o=Math.max(t,r,e),i=Math.min(t,r,e),a=o-i,p=o===0?0:a/o,b=o/255,s;switch(o){case i:s=0;break;case t:s=r-e+a*(r<e?6:0),s/=6*a;break;case r:s=e-t+a*2,s/=6*a;break;case e:s=t-r+a*4,s/=6*a;break}return{h:Math.round(s*360),s:Math.round(p*100),v:Math.round(b*100),a:n||1}}function u(t){if(typeof t!="string")throw new TypeError("Expected a string");let r=t.replace(/ /g,""),e=X.exec(r);if(e===null)return T(r);let n={r:Math.min(255,parseInt(e[2],10)),g:Math.min(255,parseInt(e[3],10)),b:Math.min(255,parseInt(e[4],10))};if(e[1]){let o=parseFloat(e[5]);n.a=Math.min(1,isNaN(o)===!0?1:o)*100}return n}function k(t,r){if(typeof t!="string")throw new TypeError("Expected a string as color");if(typeof r!="number")throw new TypeError("Expected a numeric percent");let e=u(t),n=r<0?0:255,o=Math.abs(r)/100,i=e.r,a=e.g,p=e.b;return"#"+(16777216+(Math.round((n-i)*o)+i)*65536+(Math.round((n-a)*o)+a)*256+(Math.round((n-p)*o)+p)).toString(16).slice(1)}function L(t){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b} object as color");let r=typeof t=="string"?u(t):t,e=r.r/255,n=r.g/255,o=r.b/255,i=e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4),a=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),p=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4);return .2126*i+.7152*a+.0722*p}function V(t){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b} object as color");let r=typeof t=="string"?u(t):t;return(r.r*299+r.g*587+r.b*114)/1e3}function I(t,r){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b[, a]} object as fgColor");if(typeof r!="string"&&(!r||r.r===void 0))throw new TypeError("Expected a string or a {r, g, b[, a]} object as bgColor");let e=typeof t=="string"?u(t):t,n=e.r/255,o=e.g/255,i=e.b/255,a=e.a!==void 0?e.a/100:1,p=typeof r=="string"?u(r):r,b=p.r/255,s=p.g/255,d=p.b/255,c=p.a!==void 0?p.a/100:1,f=a+c*(1-a),l=Math.round((n*a+b*c*(1-a))/f*255),x=Math.round((o*a+s*c*(1-a))/f*255),O=Math.round((i*a+d*c*(1-a))/f*255),w={r:l,g:x,b:O,a:Math.round(f*100)};return typeof t=="string"?g(w):w}function j(t,r){if(typeof t!="string")throw new TypeError("Expected a string as color");if(r===void 0||r<-1||r>1)throw new TypeError("Expected offset to be between -1 and 1");let{r:e,g:n,b:o,a:i}=u(t),a=i!==void 0?i/100:0;return g({r:e,g:n,b:o,a:Math.round(Math.min(1,Math.max(0,a+r))*100)})}function v(t,r){if(typeof t!="string")throw new TypeError("Expected a string as color");if(r===void 0||r<0||r>100)throw new TypeError("Expected alpha to be between 1 and 100");let e=u(t);return e.a=r,g(e)}var E=2,R=16,C=5,N=5,P=15,h=5,D=4;function q(t,r){if(typeof t!="string"&&(!t||t.r===void 0))throw new TypeError("Expected a string or a {r, g, b} object as color");let e=typeof t=="string"?u(t):t,n=m(e);if(r===6)return g(e);let o=r<6,i=o?h+1-r:r-h-1,a={h:F(n,i,o),s:$(n,i,o),v:z(n,i,o),a:n.a};return g(M(a))}function F(t,r,e){let n;return t.h>=60&&t.h<=240?n=e?t.h-E*r:t.h+E*r:n=e?t.h+E*r:t.h-E*r,n<0?n+=360:n>=360&&(n-=360),n}function $(t,r,e){let n;return e?n=t.s-R*r:r===D?n=t.s+R:n=t.s+C*r,n>100&&(n=100),e&&r===h&&n>10&&(n=10),n<6&&(n=6),n}function z(t,r,e){let n;return n=e?t.v+N*r:t.v-P*r,n>100&&(n=100),n}return _(J);})();
2
2
  //# sourceMappingURL=index.iife.min.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../index.ts"],
4
- "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 1) {\r\n throw new TypeError('Expected alpha to be between 0 and 1')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
- "mappings": "mbAAA,8MAWA,GAAM,GAAU,8DAaT,WAAkB,CAAE,IAAG,IAAG,IAAG,KAAe,CACjD,GAAM,GAAQ,IAAM,OAMpB,GAJA,EAAI,KAAK,MAAM,CAAC,EAChB,EAAI,KAAK,MAAM,CAAC,EAChB,EAAI,KAAK,MAAM,CAAC,EAEZ,EAAI,KAAO,EAAI,KAAO,EAAI,KAAQ,GAAS,EAAK,IAClD,KAAM,IAAI,WAAU,6DAA6D,EAGnF,MAAI,IACF,GAAI,OAAQ,MAAK,MAAO,IAAM,EAAM,GAAG,EAAK,GAAK,GAAI,SAAS,EAAE,EAAE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AAI,EAAI,EAAI,EAAU,EAE1D,AAAI,EAAM,EAAG,GAAO,IACX,GAAO,KAAK,IAAO,KAErB,CACT,CAQA,WAAoB,EAAW,EAAW,EAAkB,CAC1D,GAAI,GACJ,MAAI,GAAS,EAAa,EAAI,EAAI,EAAiB,EAC9C,AAAI,IAAM,EAAgB,EAAa,EAAI,EAAI,EAC/C,EAAa,EAAI,EAAI,EAAkB,EAExC,EAAa,KAAK,GAAa,KAE/B,GAAW,IAAM,GAAmB,EAAa,IAAI,GAAa,IAElE,EAAa,GAAG,GAAa,GAE1B,CACT,CAQA,WAAe,EAAW,EAAW,EAAkB,CACrD,GAAI,GACJ,SAAQ,EAAU,EAAI,EAAI,EAAkB,EAAI,EAAI,EAAI,EAAkB,EAEtE,EAAQ,KAAK,GAAQ,KAElB,CACT",
4
+ "sourcesContent": ["export type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HEX = string\r\nexport type HSVA = Record<'h' | 's' | 'v' | 'a', number>\r\n\r\nexport type RGBA_TEXT = string\r\nexport type HEX_TEXT = string\r\nexport type HSVA_TEXT = string\r\nexport type COLOR = RGBA_TEXT | HEX_TEXT | HSVA_TEXT\r\nexport type PALETTE_INDEXES = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10\r\n\r\nconst RE_RGBA = /^rgb(a)?\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),?([01]?\\.?\\d*?)?\\)$/\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HEX/A representation as a\r\n *\r\n * String (`#RRGGBB<AA>`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHex({ r, g, b, a }: RGB): HEX {\r\n const alpha = a !== void 0\r\n\r\n r = Math.round(r)\r\n g = Math.round(g)\r\n b = Math.round(b)\r\n\r\n if (r > 255 || g > 255 || b > 255 || (alpha && a! > 100)) {\r\n throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)')\r\n }\r\n\r\n if (alpha) {\r\n a = Number((Math.round((255 * a!) / 100) | (1 << 8)).toString(16).slice(1))\r\n }\r\n\r\n return '#' + (b | (g << 8) | (r << 16) | (1 << 24)).toString(16).slice(1) + a\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hexToRgb(hex: HEX): RGB {\r\n if (typeof hex !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n hex = hex.replace(/^#/, '')\r\n\r\n if (hex.length === 3) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]\r\n } else if (hex.length === 4) {\r\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]\r\n }\r\n\r\n const num = parseInt(hex, 16)\r\n\r\n return hex.length > 6\r\n ? { r: (num >> 24) & 255, g: (num >> 16) & 255, b: (num >> 8) & 255, a: Math.round((num & 255) / 2.55) }\r\n : { r: num >> 16, g: (num >> 8) & 255, b: num & 255 }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`) .\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function hsvToRgb({ h, s, v, a }: HSVA): RGBA {\r\n let r: any, g: any, b: any\r\n s = s / 100\r\n v = v / 100\r\n\r\n h = h / 360\r\n const i = Math.floor(h * 6),\r\n f = h * 6 - i,\r\n p = v * (1 - s),\r\n q = v * (1 - f * s),\r\n t = v * (1 - (1 - f) * s)\r\n\r\n switch (i % 6) {\r\n case 0:\r\n r = v\r\n g = t\r\n b = p\r\n break\r\n case 1:\r\n r = q\r\n g = v\r\n b = p\r\n break\r\n case 2:\r\n r = p\r\n g = v\r\n b = t\r\n break\r\n case 3:\r\n r = p\r\n g = q\r\n b = v\r\n break\r\n case 4:\r\n r = t\r\n g = p\r\n b = v\r\n break\r\n case 5:\r\n r = v\r\n g = p\r\n b = q\r\n break\r\n }\r\n\r\n return {\r\n r: Math.round(r * 255),\r\n g: Math.round(g * 255),\r\n b: Math.round(b * 255),\r\n a\r\n }\r\n}\r\n\r\n/**\r\n * Converts a RGB/A color\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`)\r\n *\r\n * to its HSV/A representation as an\r\n *\r\n * Object (`{ h: [0-360], s: [0-100], v: [0-100}, a: [0-100]}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function rgbToHsv({ r, g, b, a }: RGB): HSVA {\r\n const max = Math.max(r, g, b),\r\n min = Math.min(r, g, b),\r\n d = max - min,\r\n s = max === 0 ? 0 : d / max,\r\n v = max / 255\r\n let h: any\r\n\r\n switch (max) {\r\n case min:\r\n h = 0\r\n break\r\n case r:\r\n h = g - b + d * (g < b ? 6 : 0)\r\n h /= 6 * d\r\n break\r\n case g:\r\n h = b - r + d * 2\r\n h /= 6 * d\r\n break\r\n case b:\r\n h = r - g + d * 4\r\n h /= 6 * d\r\n break\r\n }\r\n\r\n return {\r\n h: Math.round(h * 360),\r\n s: Math.round(s * 100),\r\n v: Math.round(v * 100),\r\n a: a || 1\r\n }\r\n}\r\n\r\n/**\r\n * Converts a HEX/A color\r\n *\r\n * String (`#RRGGBB<AA>`) or a RGB/A color String(`rgb(R, G, B<, A>)`)\r\n *\r\n * to its RGB/A representation as an\r\n *\r\n * Object (`{ r: [0-255], g: [0-255], b: [0-255}<, a: [0-100]>}`).\r\n *\r\n * If Alpha channel is present in the original object it will be present also in the output.\r\n */\r\nexport function textToRgb(str: COLOR): RGB {\r\n if (typeof str !== 'string') {\r\n throw new TypeError('Expected a string')\r\n }\r\n\r\n const color = str.replace(/ /g, '')\r\n\r\n const m = RE_RGBA.exec(color)\r\n\r\n if (m === null) {\r\n return hexToRgb(color)\r\n }\r\n\r\n const rgb: RGB = {\r\n r: Math.min(255, parseInt(m[2], 10)),\r\n g: Math.min(255, parseInt(m[3], 10)),\r\n b: Math.min(255, parseInt(m[4], 10))\r\n }\r\n\r\n if (m[1]) {\r\n const alpha = parseFloat(m[5])\r\n rgb.a = Math.min(1, isNaN(alpha) === true ? 1 : alpha) * 100\r\n }\r\n\r\n return rgb\r\n}\r\n\r\n/**\r\n * Lighten the `color` (if `percent` is positive) or darken it (if `percent` is negative).\r\n *\r\n * Accepts a HEX/A String or a RGB/A String as color and a percent (0 to 100 or -100 to 0) of lighten/darken to be applied to the `color`. Returns a HEX String representation of the calculated `color`.\r\n */\r\nexport function lighten(color: COLOR, percent: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (typeof percent !== 'number') {\r\n throw new TypeError('Expected a numeric percent')\r\n }\r\n\r\n const rgb = textToRgb(color),\r\n t = percent < 0 ? 0 : 255,\r\n p = Math.abs(percent) / 100,\r\n R = rgb.r,\r\n G = rgb.g,\r\n B = rgb.b\r\n\r\n return (\r\n '#' +\r\n (\r\n 0x1_00_00_00 +\r\n (Math.round((t - R) * p) + R) * 0x1_00_00 +\r\n (Math.round((t - G) * p) + G) * 0x1_00 +\r\n (Math.round((t - B) * p) + B)\r\n )\r\n .toString(16)\r\n .slice(1)\r\n )\r\n}\r\n/**\r\n * Calculates the [relative luminance](https://www.w3.org/TR/WCAG20/#relativeluminancedef) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function luminosity(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color,\r\n r = rgb.r / 255,\r\n g = rgb.g / 255,\r\n b = rgb.b / 255,\r\n R = r <= 0.039_28 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4),\r\n G = g <= 0.039_28 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4),\r\n B = b <= 0.039_28 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4)\r\n return 0.2126 * R + 0.7152 * G + 0.0722 * B\r\n}\r\n/**\r\n * Calculates the [color contrast](https://www.w3.org/TR/AERT/#color-contrast) of the `color`.\r\n *\r\n * Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `color`. Returns a value between 0 and 1.\r\n */\r\nexport function brightness(color: COLOR | RGB) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n\r\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\r\n}\r\n\r\n/**\r\n * Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.\r\n *\r\n * Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. Returns the same type as input for fgColor.\r\n */\r\nexport function blend(fgColor: COLOR | RGB, bgColor: COLOR | RGB) {\r\n if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as fgColor')\r\n }\r\n\r\n if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b[, a]} object as bgColor')\r\n }\r\n\r\n const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\r\n r1 = rgb1.r / 255,\r\n g1 = rgb1.g / 255,\r\n b1 = rgb1.b / 255,\r\n a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\r\n rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\r\n r2 = rgb2.r / 255,\r\n g2 = rgb2.g / 255,\r\n b2 = rgb2.b / 255,\r\n a2 = rgb2.a !== void 0 ? rgb2.a / 100 : 1,\r\n a = a1 + a2 * (1 - a1),\r\n r = Math.round(((r1 * a1 + r2 * a2 * (1 - a1)) / a) * 255),\r\n g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),\r\n b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)\r\n\r\n const ret = { r, g, b, a: Math.round(a * 100) }\r\n return typeof fgColor === 'string' ? rgbToHex(ret) : ret\r\n}\r\n\r\n/**\r\n * Increments or decrements the alpha of a string color.\r\n *\r\n * Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: blendAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.\r\n */\r\nexport function blendAlpha(color: COLOR, offset: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n\r\n if (offset === void 0 || offset < -1 || offset > 1) {\r\n throw new TypeError('Expected offset to be between -1 and 1')\r\n }\r\n\r\n const { r, g, b, a } = textToRgb(color)\r\n const alpha = a !== void 0 ? a / 100 : 0\r\n\r\n return rgbToHex({\r\n r,\r\n g,\r\n b,\r\n a: Math.round(Math.min(1, Math.max(0, alpha + offset)) * 100)\r\n })\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n if (typeof color !== 'string') {\r\n throw new TypeError('Expected a string as color')\r\n }\r\n if (alpha === void 0 || alpha < 0 || alpha > 100) {\r\n throw new TypeError('Expected alpha to be between 1 and 100')\r\n }\r\n const rgba = textToRgb(color)\r\n rgba.a = alpha\r\n\r\n return rgbToHex(rgba)\r\n}\r\n\r\nconst hueStep = 2\r\nconst saturationStep = 16\r\nconst saturationStep2 = 5\r\nconst brightnessStep1 = 5\r\nconst brightnessStep2 = 15\r\nconst lightColorCount = 5\r\nconst darkColorCount = 4\r\n\r\n/**\r\n * \u6839\u636E\u989C\u8272\u83B7\u53D6\u8C03\u8272\u677F\u989C\u8272(\u4ECE\u5DE6\u81F3\u53F3\u989C\u8272\u4ECE\u6D45\u5230\u6DF1\uFF0C6\u4E3A\u4E3B\u8272\u53F7)\r\n * @param color - \u989C\u8272\r\n * @param index - \u8C03\u8272\u677F\u7684\u5BF9\u5E94\u7684\u8272\u53F7(6\u4E3A\u4E3B\u8272\u53F7)\r\n * @description \u7B97\u6CD5\u5B9E\u73B0\u4ECEant-design\u8C03\u8272\u677F\u7B97\u6CD5\u4E2D\u501F\u9274 https://github.com/ant-design/ant-design/blob/master/components/style/color/colorPalette.less\r\n */\r\nexport function colorPalette(color: COLOR | RGB, index: PALETTE_INDEXES) {\r\n if (typeof color !== 'string' && (!color || color.r === void 0)) {\r\n throw new TypeError('Expected a string or a {r, g, b} object as color')\r\n }\r\n const rgb = typeof color === 'string' ? textToRgb(color) : color\r\n const oldHsv = rgbToHsv(rgb)\r\n\r\n if (index === 6) return rgbToHex(rgb)\r\n\r\n const light = index < 6\r\n const i = light ? lightColorCount + 1 - index : index - lightColorCount - 1\r\n const newHsv: HSVA = {\r\n h: hue(oldHsv, i, light),\r\n s: saturation(oldHsv, i, light),\r\n v: value(oldHsv, i, light),\r\n a: oldHsv.a\r\n }\r\n\r\n return rgbToHex(hsvToRgb(newHsv))\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u8272\u76F8\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction hue(hsv: HSVA, i: number, isLight: boolean) {\r\n let hue: number\r\n if (hsv.h >= 60 && hsv.h <= 240) {\r\n // \u51B7\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i\r\n } else {\r\n // \u6696\u8272\u8C03\r\n // \u51CF\u6DE1\u53D8\u4EAE \u8272\u76F8\u9006\u65F6\u9488\u65CB\u8F6C \u66F4\u6696\r\n // \u52A0\u6DF1\u53D8\u6697 \u8272\u76F8\u987A\u65F6\u9488\u65CB\u8F6C \u66F4\u51B7\r\n hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i\r\n }\r\n if (hue < 0) hue += 360\r\n else if (hue >= 360) hue -= 360\r\n\r\n return hue\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u9971\u548C\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction saturation(hsv: HSVA, i: number, isLight: boolean) {\r\n let saturation: number\r\n if (isLight) saturation = hsv.s - saturationStep * i\r\n else if (i === darkColorCount) saturation = hsv.s + saturationStep\r\n else saturation = hsv.s + saturationStep2 * i\r\n\r\n if (saturation > 100) saturation = 100\r\n\r\n if (isLight && i === lightColorCount && saturation > 10) saturation = 10\r\n\r\n if (saturation < 6) saturation = 6\r\n\r\n return saturation\r\n}\r\n\r\n/**\r\n * \u83B7\u53D6\u660E\u5EA6\u6E10\u53D8\r\n * @param hsv - hsv\u683C\u5F0F\u989C\u8272\u503C\r\n * @param i - \u4E0E6\u7684\u76F8\u5BF9\u8DDD\u79BB\r\n * @param isLight - \u662F\u5426\u662F\u4EAE\u989C\u8272\r\n */\r\nfunction value(hsv: HSVA, i: number, isLight: boolean) {\r\n let value: number\r\n value = isLight ? hsv.v + brightnessStep1 * i : hsv.v - brightnessStep2 * i\r\n\r\n if (value > 100) value = 100\r\n\r\n return value\r\n}\r\n"],
5
+ "mappings": "mbAAA,8MAWA,GAAM,GAAU,8DAaT,WAAkB,CAAE,IAAG,IAAG,IAAG,KAAe,CACjD,GAAM,GAAQ,IAAM,OAMpB,GAJA,EAAI,KAAK,MAAM,CAAC,EAChB,EAAI,KAAK,MAAM,CAAC,EAChB,EAAI,KAAK,MAAM,CAAC,EAEZ,EAAI,KAAO,EAAI,KAAO,EAAI,KAAQ,GAAS,EAAK,IAClD,KAAM,IAAI,WAAU,6DAA6D,EAGnF,MAAI,IACF,GAAI,OAAQ,MAAK,MAAO,IAAM,EAAM,GAAG,EAAK,GAAK,GAAI,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,GAGrE,IAAO,GAAK,GAAK,EAAM,GAAK,GAAO,GAAK,IAAK,SAAS,EAAE,EAAE,MAAM,CAAC,EAAI,CAC9E,CAaO,WAAkB,EAAe,CACtC,GAAI,MAAO,IAAQ,SACjB,KAAM,IAAI,WAAU,mBAAmB,EAGzC,EAAM,EAAI,QAAQ,KAAM,EAAE,EAE1B,AAAI,EAAI,SAAW,EACjB,EAAM,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,GAC9C,EAAI,SAAW,GACxB,GAAM,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,GAAK,EAAI,IAG3E,GAAM,GAAM,SAAS,EAAK,EAAE,EAE5B,MAAO,GAAI,OAAS,EAChB,CAAE,EAAI,GAAO,GAAM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79,6 @@ Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`. If the alpha ch
79
79
  ### changeAlpha(color, offset)
80
80
  Increments or decrements the alpha of a string color.
81
81
 
82
- Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: changeAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.
82
+ Accepts a HEX/A String as color and a number between -1 and 1 (including edges) as offset. Use a negative value to decrement and a positive number to increment (ex: changeAlpha('#ff0000', -0.1) to decrement alpha by 10%). Returns HEX/A String.
83
+
84
+ ###
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hairy/palette",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "main": "index.cjs.js",
5
5
  "publishConfig": {
6
6
  "jsdelivr": "./index.iife.min.js"