@hairy/palette 0.3.2 → 0.3.3
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/index.cjs.js +22 -168
- package/index.cjs.js.map +2 -2
- package/index.d.ts +17 -25
- package/index.esm.js +18 -166
- package/index.esm.js.map +2 -2
- package/index.iife.js +28 -166
- package/index.iife.js.map +2 -2
- package/index.iife.min.js +1 -1
- package/index.iife.min.js.map +2 -2
- package/package.json +4 -1
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 > 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": "
|
|
4
|
+
"sourcesContent": ["import { colord, extend, AnyColor, RgbaColor, HsvaColor } from 'colord'\r\nimport a11yPlugin from 'colord/plugins/a11y'\r\nimport mixPlugin from 'colord/plugins/mix'\r\n\r\nextend([a11yPlugin, mixPlugin])\r\nexport type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HexColor = 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\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 }: RgbaColor): HexColor {\r\n return colord({ r, g, b, a }).toHex()\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: HexColor): RgbaColor {\r\n return colord(hex).toRgb()\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 }: HsvaColor): RgbaColor {\r\n return colord({ h, s, v, a }).toRgb()\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-1]}`).\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 }: RgbaColor): HsvaColor {\r\n return colord({ r, b, g, a }).toHsv()\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: AnyColor): RgbaColor {\r\n return colord(str).toRgb()\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 1 or -1 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: AnyColor, percent: number) {\r\n return colord(color).lighten(percent).toHex()\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 luminance(color: AnyColor) {\r\n return colord(color).luminance()\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: AnyColor) {\r\n return colord(color).brightness()\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: AnyColor, bgColor: AnyColor) {\r\n return colord(fgColor).mix(bgColor)\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n return colord(color).alpha(alpha).toHex()\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: string | RgbaColor, 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 = colord(rgb).toHsv()\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 = {\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 return colord(newHsv).toHex()\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: HsvaColor, 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: HsvaColor, 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: HsvaColor, 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": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/index.iife.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var HairyPalette=(()=>{var
|
|
1
|
+
var HairyPalette=(()=>{var R=Object.create;var l=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var p=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(t,e)=>(typeof require!="undefined"?require:t)[e]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+o+'" is not supported')});var h=(o,t)=>{for(var e in t)l(o,e,{get:t[e],enumerable:!0})},b=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of y(t))!A.call(o,u)&&u!==e&&l(o,u,{get:()=>t[u],enumerable:!(r=T(t,u))||r.enumerable});return o};var g=(o,t,e)=>(e=o!=null?R(E(o)):{},b(t||!o||!o.__esModule?l(e,"default",{value:o,enumerable:!0}):e,o)),v=o=>b(l({},"__esModule",{value:!0}),o);var q={};h(q,{blend:()=>G,brightness:()=>B,changeAlpha:()=>O,colorPalette:()=>L,hexToRgb:()=>S,hsvToRgb:()=>X,lighten:()=>d,luminance:()=>P,rgbToHex:()=>C,rgbToHsv:()=>_,textToRgb:()=>H});var n=p("colord"),x=g(p("colord/plugins/a11y")),f=g(p("colord/plugins/mix"));(0,n.extend)([x.default,f.default]);function C({r:o,g:t,b:e,a:r}){return(0,n.colord)({r:o,g:t,b:e,a:r}).toHex()}function S(o){return(0,n.colord)(o).toRgb()}function X({h:o,s:t,v:e,a:r}){return(0,n.colord)({h:o,s:t,v:e,a:r}).toRgb()}function _({r:o,g:t,b:e,a:r}){return(0,n.colord)({r:o,b:e,g:t,a:r}).toHsv()}function H(o){return(0,n.colord)(o).toRgb()}function d(o,t){return(0,n.colord)(o).lighten(t).toHex()}function P(o){return(0,n.colord)(o).luminance()}function B(o){return(0,n.colord)(o).brightness()}function G(o,t){return(0,n.colord)(o).mix(t)}function O(o,t){return(0,n.colord)(o).alpha(t).toHex()}var s=2,c=16,w=5,V=5,D=15,i=5,I=4;function L(o,t){if(typeof o!="string"&&(!o||o.r===void 0))throw new TypeError("Expected a string or a {r, g, b} object as color");let e=typeof o=="string"?H(o):o,r=(0,n.colord)(e).toHsv();if(t===6)return C(e);let u=t<6,a=u?i+1-t:t-i-1,m={h:N(r,a,u),s:j(r,a,u),v:k(r,a,u),a:r.a};return(0,n.colord)(m).toHex()}function N(o,t,e){let r;return o.h>=60&&o.h<=240?r=e?o.h-s*t:o.h+s*t:r=e?o.h+s*t:o.h-s*t,r<0?r+=360:r>=360&&(r-=360),r}function j(o,t,e){let r;return e?r=o.s-c*t:t===I?r=o.s+c:r=o.s+w*t,r>100&&(r=100),e&&t===i&&r>10&&(r=10),r<6&&(r=6),r}function k(o,t,e){let r;return r=e?o.v+V*t:o.v-D*t,r>100&&(r=100),r}return v(q);})();
|
|
2
2
|
//# sourceMappingURL=index.iife.min.js.map
|
package/index.iife.min.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 > 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": "
|
|
4
|
+
"sourcesContent": ["import { colord, extend, AnyColor, RgbaColor, HsvaColor } from 'colord'\r\nimport a11yPlugin from 'colord/plugins/a11y'\r\nimport mixPlugin from 'colord/plugins/mix'\r\n\r\nextend([a11yPlugin, mixPlugin])\r\nexport type RGBA = Record<'r' | 'g' | 'b' | 'a', number>\r\nexport type RGB = Record<'r' | 'g' | 'b', number> & { a?: number }\r\nexport type HexColor = 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\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 }: RgbaColor): HexColor {\r\n return colord({ r, g, b, a }).toHex()\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: HexColor): RgbaColor {\r\n return colord(hex).toRgb()\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 }: HsvaColor): RgbaColor {\r\n return colord({ h, s, v, a }).toRgb()\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-1]}`).\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 }: RgbaColor): HsvaColor {\r\n return colord({ r, b, g, a }).toHsv()\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: AnyColor): RgbaColor {\r\n return colord(str).toRgb()\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 1 or -1 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: AnyColor, percent: number) {\r\n return colord(color).lighten(percent).toHex()\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 luminance(color: AnyColor) {\r\n return colord(color).luminance()\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: AnyColor) {\r\n return colord(color).brightness()\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: AnyColor, bgColor: AnyColor) {\r\n return colord(fgColor).mix(bgColor)\r\n}\r\n\r\n/**\r\n * Change color transparency\r\n */\r\nexport function changeAlpha(color: COLOR, alpha: number) {\r\n return colord(color).alpha(alpha).toHex()\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: string | RgbaColor, 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 = colord(rgb).toHsv()\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 = {\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 return colord(newHsv).toHex()\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: HsvaColor, 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: HsvaColor, 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: HsvaColor, 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": "q2BAAA,kMAA+D,YAC/D,EAAuB,4BACvB,EAAsB,2BAEtB,aAAO,CAAC,UAAY,SAAS,CAAC,EAuBvB,WAAkB,CAAE,IAAG,IAAG,IAAG,KAA0B,CAC5D,MAAO,aAAO,CAAE,IAAG,IAAG,IAAG,GAAE,CAAC,EAAE,MAAM,CACtC,CAaO,WAAkB,EAA0B,CACjD,MAAO,aAAO,CAAG,EAAE,MAAM,CAC3B,CAaO,WAAkB,CAAE,IAAG,IAAG,IAAG,KAA2B,CAC7D,MAAO,aAAO,CAAE,IAAG,IAAG,IAAG,GAAE,CAAC,EAAE,MAAM,CACtC,CAaO,WAAkB,CAAE,IAAG,IAAG,IAAG,KAA2B,CAC7D,MAAO,aAAO,CAAE,IAAG,IAAG,IAAG,GAAE,CAAC,EAAE,MAAM,CACtC,CAaO,WAAmB,EAA0B,CAClD,MAAO,aAAO,CAAG,EAAE,MAAM,CAC3B,CAOO,WAAiB,EAAiB,EAAiB,CACxD,MAAO,aAAO,CAAK,EAAE,QAAQ,CAAO,EAAE,MAAM,CAC9C,CAMO,WAAmB,EAAiB,CACzC,MAAO,aAAO,CAAK,EAAE,UAAU,CACjC,CAMO,WAAoB,EAAiB,CAC1C,MAAO,aAAO,CAAK,EAAE,WAAW,CAClC,CAOO,WAAe,EAAmB,EAAmB,CAC1D,MAAO,aAAO,CAAO,EAAE,IAAI,CAAO,CACpC,CAKO,WAAqB,EAAc,EAAe,CACvD,MAAO,aAAO,CAAK,EAAE,MAAM,CAAK,EAAE,MAAM,CAC1C,CAEA,GAAM,GAAU,EACV,EAAiB,GACjB,EAAkB,EAClB,EAAkB,EAClB,EAAkB,GAClB,EAAkB,EAClB,EAAiB,EAQhB,WAAsB,EAA2B,EAAwB,CAC9E,GAAI,MAAO,IAAU,UAAa,EAAC,GAAS,EAAM,IAAM,QACtD,KAAM,IAAI,WAAU,kDAAkD,EAExE,GAAM,GAAM,MAAO,IAAU,SAAW,EAAU,CAAK,EAAI,EACrD,EAAS,aAAO,CAAG,EAAE,MAAM,EAEjC,GAAI,IAAU,EAAG,MAAO,GAAS,CAAG,EAEpC,GAAM,GAAQ,EAAQ,EAChB,EAAI,EAAQ,EAAkB,EAAI,EAAQ,EAAQ,EAAkB,EACpE,EAAS,CACb,EAAG,EAAI,EAAQ,EAAG,CAAK,EACvB,EAAG,EAAW,EAAQ,EAAG,CAAK,EAC9B,EAAG,EAAM,EAAQ,EAAG,CAAK,EACzB,EAAG,EAAO,CACZ,EACA,MAAO,aAAO,CAAM,EAAE,MAAM,CAC9B,CAQA,WAAa,EAAgB,EAAW,EAAkB,CACxD,GAAI,GACJ,MAAI,GAAI,GAAK,IAAM,EAAI,GAAK,IAI1B,EAAM,EAAU,EAAI,EAAI,EAAU,EAAI,EAAI,EAAI,EAAU,EAKxD,EAAM,EAAU,EAAI,EAAI,EAAU,EAAI,EAAI,EAAI,EAAU,EAE1D,AAAI,EAAM,EAAG,GAAO,IACX,GAAO,KAAK,IAAO,KAErB,CACT,CAQA,WAAoB,EAAgB,EAAW,EAAkB,CAC/D,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,EAAgB,EAAW,EAAkB,CAC1D,GAAI,GACJ,SAAQ,EAAU,EAAI,EAAI,EAAkB,EAAI,EAAI,EAAI,EAAkB,EAEtE,EAAQ,KAAK,GAAQ,KAElB,CACT",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hairy/palette",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"main": "index.cjs.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"jsdelivr": "./index.iife.min.js"
|
|
7
7
|
},
|
|
8
8
|
"license": "MIT",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"colord": "^2.9.3"
|
|
11
|
+
},
|
|
9
12
|
"scripts": {
|
|
10
13
|
"build": "hairy build --esllpkg --type"
|
|
11
14
|
},
|