color-2-name 1.0.2 → 1.0.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/LICENSE +7 -0
- package/colorSetUtils.mjs +43 -12
- package/dist/color-2-name.js +1 -1
- package/dist/color-2-name.js.map +1 -1
- package/dist/color-utils.d.ts +2 -2
- package/dist/common.d.ts +18 -4
- package/dist/hex-utils.d.ts +16 -2
- package/dist/hsl-utils.d.ts +20 -3
- package/dist/index.d.ts +32 -10
- package/dist/rgb-utils.d.ts +15 -2
- package/package.json +22 -14
- package/readme.md +38 -19
- package/.editorconfig +0 -15
- package/.eslintrc.js +0 -14
- package/.github/workflows/node.js.yml +0 -32
- package/babel.config.json +0 -6
- package/docs/color-2-name.js +0 -2
- package/docs/color-2-name.js.map +0 -1
- package/docs/index.html +0 -58
- package/docs/index.js +0 -35
- package/docs/web-component.js +0 -85
- package/src/color-utils.ts +0 -26
- package/src/common.ts +0 -129
- package/src/data/altColorSet.json +0 -5210
- package/src/data/colorSet.ts +0 -850
- package/src/data/css.json +0 -143
- package/src/hex-utils.ts +0 -71
- package/src/hsl-utils.ts +0 -121
- package/src/index.ts +0 -121
- package/src/rgb-utils.ts +0 -40
- package/src/types/index.d.ts +0 -28
- package/tests/colors.test.ts +0 -188
- package/tests/index.test.ts +0 -103
- package/tsconfig.json +0 -23
- package/tsconfig.test.json +0 -18
- package/webpack.config.js +0 -48
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# [ISC License](https://spdx.org/licenses/ISC)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Erik Golinelli <erik@codekraft.it>
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/colorSetUtils.mjs
CHANGED
|
@@ -19,27 +19,58 @@ export function buildColorSet (colorSet) {
|
|
|
19
19
|
return colors
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param newSet
|
|
25
|
+
* @param filename
|
|
26
|
+
*
|
|
27
|
+
* @return {boolean} true whenever the file is successfully written
|
|
28
|
+
*/
|
|
29
|
+
export function processSet (newSet, filename) {
|
|
23
30
|
const generated = buildColorSet(newSet)
|
|
24
|
-
const setName = `const
|
|
31
|
+
const setName = `const ${filename}: RGBCOLORDEF[] = `
|
|
25
32
|
const exportName = `
|
|
26
33
|
|
|
27
|
-
export default ${filename}
|
|
34
|
+
export default ${filename}`
|
|
28
35
|
|
|
29
36
|
const generatedJson = setName + JSON.stringify(generated, null, 2) + exportName
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
console.log('Writing into ./src/data/' + filename + '.ts')
|
|
39
|
+
|
|
40
|
+
fs.writeFileSync('./src/data/' + filename + '.ts', generatedJson, {
|
|
41
|
+
encoding: 'utf8'
|
|
42
|
+
}, (err, data) => {
|
|
43
|
+
if (err) return false;
|
|
35
44
|
console.log(data)
|
|
45
|
+
return true
|
|
36
46
|
})
|
|
37
47
|
}
|
|
38
48
|
|
|
49
|
+
/**
|
|
50
|
+
* This function will read the data from a json file then output it into a ts file that contains the colorSet data into a compatible format with this module
|
|
51
|
+
*
|
|
52
|
+
* @param {*} filename
|
|
53
|
+
* @param {string} fileUri
|
|
54
|
+
*/
|
|
55
|
+
export function generateColorSet(filename, fileUri) {
|
|
56
|
+
console.log('Reading ' + fileUri)
|
|
57
|
+
const set = fs.readFileSync(fileUri, 'utf8').replace(/\r\n/g, '\n').toString()
|
|
58
|
+
|
|
59
|
+
/** the json with the colorSet */
|
|
60
|
+
const jsonSet = JSON.parse(set)
|
|
61
|
+
|
|
62
|
+
processSet(jsonSet, filename)
|
|
63
|
+
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
66
|
+
|
|
39
67
|
const filename = process.argv[2].replace(/[^a-z0-9]/gi, '')
|
|
40
68
|
const fileUri = './src/data/' + filename + '.json'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
console.log(
|
|
45
|
-
|
|
69
|
+
|
|
70
|
+
/** Create the colorset then output the result */
|
|
71
|
+
if ( generateColorSet(filename, fileUri) ) {
|
|
72
|
+
console.log('😎 Successfully created colors set ./src/data/' + filename + '.ts')
|
|
73
|
+
} else {
|
|
74
|
+
console.log( '😓 Something went wrong! cannot create colors set ./src/data/' + filename + '.ts')
|
|
75
|
+
}
|
|
76
|
+
process.exit(0)
|
package/dist/color-2-name.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("color2name",[],r):"object"==typeof exports?exports.color2name=r():e.color2name=r()}(this,(()=>(()=>{"use strict";var e={d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{closest:()=>S,closestRGB:()=>P,colorSet:()=>t,distance:()=>q,isDark:()=>E,isLight:()=>M,isLightOrDark:()=>I,rgbToHex:()=>A});const t=[[255,255,255,"white"],[0,0,0,"black"],[255,0,0,"red"],[0,128,0,"green"],[0,0,255,"blue"],[255,165,0,"orange"],[128,128,128,"grey"],[255,255,0,"yellow"],[255,0,255,"magenta"],[154,205,50,"yellowgreen"],[192,192,192,"silver"],[0,255,0,"lime"],[128,0,128,"purple"],[255,99,71,"tomato"],[64,224,208,"turquoise"],[255,127,80,"coral"],[0,255,255,"cyan"],[255,250,240,"floralwhite"],[255,192,203,"pink"],[34,139,34,"forestgreen"],[245,245,220,"beige"],[255,0,255,"fuchsia"],[220,220,220,"gainsboro"],[248,248,255,"ghostwhite"],[255,215,0,"gold"],[218,165,32,"goldenrod"],[173,255,47,"greenyellow"],[238,130,238,"violet"],[245,222,179,"wheat"],[245,245,245,"whitesmoke"],[139,0,0,"darkred"],[240,248,255,"aliceblue"],[205,92,92,"indianred"],[75,0,130,"indigo"],[250,235,215,"antiquewhite"],[0,255,255,"aqua"],[127,255,212,"aquamarine"],[240,255,255,"azure"],[255,228,196,"bisque"],[255,235,205,"blanchedalmond"],[138,43,226,"blueviolet"],[165,42,42,"brown"],[222,184,135,"burlywood"],[95,158,160,"cadetblue"],[127,255,0,"chartreuse"],[210,105,30,"chocolate"],[100,149,237,"cornflowerblue"],[255,248,220,"cornsilk"],[220,20,60,"crimson"],[0,0,139,"darkblue"],[0,139,139,"darkcyan"],[184,134,11,"darkgoldenrod"],[169,169,169,"darkgrey"],[0,100,0,"darkgreen"],[189,183,107,"darkkhaki"],[139,0,139,"darkmagenta"],[85,107,47,"darkolivegreen"],[255,140,0,"darkorange"],[153,50,204,"darkorchid"],[233,150,122,"darksalmon"],[143,188,143,"darkseagreen"],[72,61,139,"darkslateblue"],[47,79,79,"darkslategrey"],[0,206,209,"darkturquoise"],[148,0,211,"darkviolet"],[255,20,147,"deeppink"],[0,191,255,"deepskyblue"],[105,105,105,"dimgrey"],[30,144,255,"dodgerblue"],[178,34,34,"firebrick"],[240,255,240,"honeydew"],[255,105,180,"hotpink"],[255,255,240,"ivory"],[240,230,140,"khaki"],[230,230,250,"lavender"],[255,240,245,"lavenderblush"],[124,252,0,"lawngreen"],[255,250,205,"lemonchiffon"],[173,216,230,"lightblue"],[240,128,128,"lightcoral"],[224,255,255,"lightcyan"],[250,250,210,"lightgoldenrodyellow"],[144,238,144,"lightgreen"],[211,211,211,"lightgrey"],[255,182,193,"lightpink"],[255,160,122,"lightsalmon"],[32,178,170,"lightseagreen"],[135,206,250,"lightskyblue"],[119,136,153,"lightslategrey"],[176,196,222,"lightsteelblue"],[255,255,224,"lightyellow"],[50,205,50,"limegreen"],[250,240,230,"linen"],[128,0,0,"maroon"],[102,205,170,"mediumaquamarine"],[0,0,205,"mediumblue"],[186,85,211,"mediumorchid"],[147,112,219,"mediumpurple"],[60,179,113,"mediumseagreen"],[123,104,238,"mediumslateblue"],[0,250,154,"mediumspringgreen"],[72,209,204,"mediumturquoise"],[199,21,133,"mediumvioletred"],[25,25,112,"midnightblue"],[245,255,250,"mintcream"],[255,228,225,"mistyrose"],[255,228,181,"moccasin"],[255,222,173,"navajowhite"],[0,0,128,"navy"],[253,245,230,"oldlace"],[128,128,0,"olive"],[107,142,35,"olivedrab"],[255,69,0,"orangered"],[218,112,214,"orchid"],[238,232,170,"palegoldenrod"],[152,251,152,"palegreen"],[175,238,238,"paleturquoise"],[219,112,147,"palevioletred"],[255,239,213,"papayawhip"],[255,218,185,"peachpuff"],[205,133,63,"peru"],[221,160,221,"plum"],[176,224,230,"powderblue"],[102,51,153,"rebeccapurple"],[188,143,143,"rosybrown"],[65,105,225,"royalblue"],[139,69,19,"saddlebrown"],[250,128,114,"salmon"],[244,164,96,"sandybrown"],[46,139,87,"seagreen"],[255,245,238,"seashell"],[160,82,45,"sienna"],[135,206,235,"skyblue"],[106,90,205,"slateblue"],[112,128,144,"slategrey"],[255,250,250,"snow"],[0,255,127,"springgreen"],[70,130,180,"steelblue"],[210,180,140,"tan"],[0,128,128,"teal"],[216,191,216,"thistle"]];function n(e){var r="#"===Array.from(e)[0]?e.substring(1):e;if(r.length>2){if(r.length<6)return function(e){return Array.from(e).map((function(e){return(e+e).toUpperCase()}))}(r);var t=r.match(/../g);return null!=t?[t[0].toUpperCase(),t[1].toUpperCase(),t[2].toUpperCase()]:[]}return[]}function o(e){return e.toString(16).padStart(2,"0")}function a(e){return"number"==typeof(null==e?void 0:e.r)&&"number"==typeof(null==e?void 0:e.g)&&"number"==typeof(null==e?void 0:e.b)?"#".concat(o(null==e?void 0:e.r)).concat(o(null==e?void 0:e.g)).concat(o(null==e?void 0:e.b)):"#errorr"}function i(e){var r=e.match(f);if(null!=r){var t=b(r[1]);if(t.length>=2)return[t[0],t[1],t[2]]}throw new Error("Can't parse rgb color: ".concat(e))}function l(e){if(e.length>=2)return{r:p(e[0]),g:p(e[1]),b:p(e[2])};throw new Error("Invalid rgb color: ".concat(e.join(", ")))}function u(e){if(null===e||e.length<2)throw new Error("Invalid hsl color: ".concat(e.join(", ")));var r=function(e){if(e.length>=2)return{h:p(e[0]),s:p(e[1],100),l:p(e[2],100)};throw new Error("Invalid hsl color: ".concat(e.join(", ")))}(e),t=r.h,n=r.s,o=r.l;n/=100,o/=100;var a=(1-Math.abs(2*o-1))*n,i=a*(1-Math.abs(t/60%2-1)),l=o-a/2,u=0,c=0,f=0;return t>=0&&t<60?(u=a,c=i,f=0):t>=60&&t<120?(u=i,c=a,f=0):t>=120&&t<180?(u=0,c=a,f=i):t>=180&&t<240?(u=0,c=i,f=a):t>=240&&t<300?(u=i,c=0,f=a):t>=300&&t<360&&(u=a,c=0,f=i),{r:u=Math.round(255*(u+l)),g:c=Math.round(255*(c+l)),b:f=Math.round(255*(f+l))}}var c=/^#([\da-f]{6,}|[\da-f]{3,})/i,f=/^rgba?\(([^)]+)\)/i,s=/^hsla?\(([^)]+)\)/i,d=/^[0-9]*$/,g=[[255,255,255,"white"],[1,1,1,"black"]],h=[[255,0,0,"red"],[0,255,0,"green"],[0,0,255,"blue"]];function b(e){return e.includes(",")?e.split(/[,\\/]/).map((function(e){return e.trim()})):e.split(/[ \\/]/).map((function(e){return e.trim()})).filter(Boolean)}function p(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:255;if(e=e.trim(),d.test(e))return parseInt(e,10);if(e.endsWith("%"))return parseFloat(e)/100*r;if(e.endsWith("deg")){for(var t=parseFloat(e);t<0;)t+=360;for(;t>360;)t-=360;return t/360*r}throw new Error("Invalid value: ".concat(e))}function m(e){if(c.test(e)){var r=n(e);if(r.length>0)return function(e){if(e.length>=2)return{r:parseInt(e[0],16),g:parseInt(e[1],16),b:parseInt(e[2],16)};throw new Error("Invalid Hex color: ".concat(e.join(", ")))}(r)}else if(f.test(e)){var t=i(e);if(t.length>0)return l(t)}else if(s.test(e)){var o=function(e){var r=e.match(s);if(null!=r){var t=b(r[1]);if(t.length>=2)return[t[0],t[1],t[2]]}throw new Error("Can't parse hsl color: ".concat(e))}(e);if(o.length>0)return u(o)}throw new Error("Invalid color: ".concat(e))}function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function v(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function w(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?v(Object(t),!0).forEach((function(r){k(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):v(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function k(e,r,t){return(r=function(e){var r=function(e,r){if("object"!==y(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!==y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"===y(r)?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function j(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(!e)return;if("string"==typeof e)return O(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,r)}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){l=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(l)throw a}}}}function O(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function S(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=Number.MAX_SAFE_INTEGER,o={name:"error",color:"#F00"};if(r.length<1)return o;var i=Object.values(m(e));if(i.length>2){var l,u=j(r);try{for(u.s();!(l=u.n()).done;){var c=l.value,f=q(i,c,!0);if(f<n&&(n=f,o.name=c[3],o.color="rgb(".concat(c[0],",").concat(c[1],",").concat(c[2],")")),0===f)break}}catch(e){u.e(e)}finally{u.f()}}for(var s=arguments.length,d=new Array(s>2?s-2:0),g=2;g<s;g++)d[g-2]=arguments[g];if((null==d?void 0:d.length)>0&&null!==(null==d?void 0:d.info)){var h=m(o.color),b=a(h);return w(w({},o),{},{hex:b,gap:Math.sqrt(n)})}return o}function M(e){return"white"===S(e,g).name}function E(e){return"black"===S(e,g).name}function I(e){return M(e)?"light":"dark"}function P(e){return S(e,h).name}function q(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t?Math.pow(r[0]-e[0],2)+Math.pow(r[1]-e[1],2)+Math.pow(r[2]-e[2],2):Math.sqrt(Math.pow(r[0]-e[0],2)+Math.pow(r[1]-e[1],2)+Math.pow(r[2]-e[2],2))}function A(e){if(f.test(e)){var r=i(e);if(r.length>0)return a(l(r))}throw new Error("Invalid color: ".concat(e))}return r})()));
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("color2name",[],r):"object"==typeof exports?exports.color2name=r():e.color2name=r()}(this,(()=>(()=>{"use strict";var e={d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{closest:()=>S,closestRGB:()=>P,colorSet:()=>t,distance:()=>q,isDark:()=>E,isLight:()=>M,isLightOrDark:()=>I,rgbToHex:()=>A});const t=[[255,255,255,"white"],[0,0,0,"black"],[255,0,0,"red"],[0,128,0,"green"],[0,0,255,"blue"],[255,165,0,"orange"],[128,128,128,"grey"],[255,255,0,"yellow"],[255,0,255,"magenta"],[154,205,50,"yellowgreen"],[192,192,192,"silver"],[0,255,0,"lime"],[128,0,128,"purple"],[255,99,71,"tomato"],[64,224,208,"turquoise"],[255,127,80,"coral"],[0,255,255,"cyan"],[255,250,240,"floralwhite"],[255,192,203,"pink"],[34,139,34,"forestgreen"],[245,245,220,"beige"],[255,0,255,"fuchsia"],[220,220,220,"gainsboro"],[248,248,255,"ghostwhite"],[255,215,0,"gold"],[218,165,32,"goldenrod"],[173,255,47,"greenyellow"],[238,130,238,"violet"],[245,222,179,"wheat"],[245,245,245,"whitesmoke"],[139,0,0,"darkred"],[240,248,255,"aliceblue"],[205,92,92,"indianred"],[75,0,130,"indigo"],[250,235,215,"antiquewhite"],[0,255,255,"aqua"],[127,255,212,"aquamarine"],[240,255,255,"azure"],[255,228,196,"bisque"],[255,235,205,"blanchedalmond"],[138,43,226,"blueviolet"],[165,42,42,"brown"],[222,184,135,"burlywood"],[95,158,160,"cadetblue"],[127,255,0,"chartreuse"],[210,105,30,"chocolate"],[100,149,237,"cornflowerblue"],[255,248,220,"cornsilk"],[220,20,60,"crimson"],[0,0,139,"darkblue"],[0,139,139,"darkcyan"],[184,134,11,"darkgoldenrod"],[169,169,169,"darkgrey"],[0,100,0,"darkgreen"],[189,183,107,"darkkhaki"],[139,0,139,"darkmagenta"],[85,107,47,"darkolivegreen"],[255,140,0,"darkorange"],[153,50,204,"darkorchid"],[233,150,122,"darksalmon"],[143,188,143,"darkseagreen"],[72,61,139,"darkslateblue"],[47,79,79,"darkslategrey"],[0,206,209,"darkturquoise"],[148,0,211,"darkviolet"],[255,20,147,"deeppink"],[0,191,255,"deepskyblue"],[105,105,105,"dimgrey"],[30,144,255,"dodgerblue"],[178,34,34,"firebrick"],[240,255,240,"honeydew"],[255,105,180,"hotpink"],[255,255,240,"ivory"],[240,230,140,"khaki"],[230,230,250,"lavender"],[255,240,245,"lavenderblush"],[124,252,0,"lawngreen"],[255,250,205,"lemonchiffon"],[173,216,230,"lightblue"],[240,128,128,"lightcoral"],[224,255,255,"lightcyan"],[250,250,210,"lightgoldenrodyellow"],[144,238,144,"lightgreen"],[211,211,211,"lightgrey"],[255,182,193,"lightpink"],[255,160,122,"lightsalmon"],[32,178,170,"lightseagreen"],[135,206,250,"lightskyblue"],[119,136,153,"lightslategrey"],[176,196,222,"lightsteelblue"],[255,255,224,"lightyellow"],[50,205,50,"limegreen"],[250,240,230,"linen"],[128,0,0,"maroon"],[102,205,170,"mediumaquamarine"],[0,0,205,"mediumblue"],[186,85,211,"mediumorchid"],[147,112,219,"mediumpurple"],[60,179,113,"mediumseagreen"],[123,104,238,"mediumslateblue"],[0,250,154,"mediumspringgreen"],[72,209,204,"mediumturquoise"],[199,21,133,"mediumvioletred"],[25,25,112,"midnightblue"],[245,255,250,"mintcream"],[255,228,225,"mistyrose"],[255,228,181,"moccasin"],[255,222,173,"navajowhite"],[0,0,128,"navy"],[253,245,230,"oldlace"],[128,128,0,"olive"],[107,142,35,"olivedrab"],[255,69,0,"orangered"],[218,112,214,"orchid"],[238,232,170,"palegoldenrod"],[152,251,152,"palegreen"],[175,238,238,"paleturquoise"],[219,112,147,"palevioletred"],[255,239,213,"papayawhip"],[255,218,185,"peachpuff"],[205,133,63,"peru"],[221,160,221,"plum"],[176,224,230,"powderblue"],[102,51,153,"rebeccapurple"],[188,143,143,"rosybrown"],[65,105,225,"royalblue"],[139,69,19,"saddlebrown"],[250,128,114,"salmon"],[244,164,96,"sandybrown"],[46,139,87,"seagreen"],[255,245,238,"seashell"],[160,82,45,"sienna"],[135,206,235,"skyblue"],[106,90,205,"slateblue"],[112,128,144,"slategrey"],[255,250,250,"snow"],[0,255,127,"springgreen"],[70,130,180,"steelblue"],[210,180,140,"tan"],[0,128,128,"teal"],[216,191,216,"thistle"]];function n(e){var r="#"===Array.from(e)[0]?e.substring(1):e;if(r.length>2){if(r.length<6)return function(e){return Array.from(e).map((function(e){return(e+e).toUpperCase()}))}(r);var t=r.match(/../g);return null!=t?[t[0].toUpperCase(),t[1].toUpperCase(),t[2].toUpperCase()]:[]}return[]}function o(e){return e.toString(16).padStart(2,"0")}function a(e){return"number"==typeof(null==e?void 0:e.r)&&"number"==typeof(null==e?void 0:e.g)&&"number"==typeof(null==e?void 0:e.b)?"#".concat(o(null==e?void 0:e.r)).concat(o(null==e?void 0:e.g)).concat(o(null==e?void 0:e.b)):"#errorr"}function i(e){var r=e.match(f);if(null!=r){var t=p(r[1]);if(t.length>=2)return[t[0],t[1],t[2]]}throw new Error("Can't parse rgb color: ".concat(e))}function l(e){if(e.length>=2)return{r:b(e[0]),g:b(e[1]),b:b(e[2])};throw new Error("Invalid rgb color: ".concat(e.join(", ")))}function u(e){if(null===e||e.length<2)throw new Error("Invalid hsl color: ".concat(e.join(", ")));var r=function(e){if(e.length>=2)return{h:parseInt(e[0],10),s:b(e[1],100),l:b(e[2],100)};throw new Error("Invalid hsl color: ".concat(e.join(", ")))}(e),t=r.h,n=r.s,o=r.l;n/=100,o/=100;var a=(1-Math.abs(2*o-1))*n,i=a*(1-Math.abs(t/60%2-1)),l=o-a/2,u=0,c=0,f=0;return t>=0&&t<60?(u=a,c=i,f=0):t>=60&&t<120?(u=i,c=a,f=0):t>=120&&t<180?(u=0,c=a,f=i):t>=180&&t<240?(u=0,c=i,f=a):t>=240&&t<300?(u=i,c=0,f=a):t>=300&&t<360&&(u=a,c=0,f=i),{r:u=Math.round(255*(u+l)),g:c=Math.round(255*(c+l)),b:f=Math.round(255*(f+l))}}var c=/^#([\da-f]{6,}|[\da-f]{3,})/i,f=/^rgba?\(([^)]+)\)/i,s=/^hsla?\(([^)]+)\)/i,d=/^[0-9]*$/,g=[[255,255,255,"white"],[1,1,1,"black"]],h=[[255,0,0,"red"],[0,255,0,"green"],[0,0,255,"blue"]];function p(e){return e.includes(",")?e.split(/[,\\/]/).map((function(e){return e.trim()})):e.split(/[ \\/]/).map((function(e){return e.trim()})).filter(Boolean)}function b(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:255;if(e=e.trim(),d.test(e))return parseInt(e,10);if(e.endsWith("%"))return parseFloat(e)/100*r;if(e.endsWith("deg")){for(var t=parseFloat(e);t<0;)t+=360;for(;t>360;)t-=360;return t/360*r}throw new Error("Invalid value: ".concat(e))}function m(e){if(c.test(e)){var r=n(e);if(r.length>0)return function(e){if(e.length>=2)return{r:parseInt(e[0],16),g:parseInt(e[1],16),b:parseInt(e[2],16)};throw new Error("Invalid Hex color: ".concat(e.join(", ")))}(r)}else if(f.test(e)){var t=i(e);if(t.length>0)return l(t)}else if(s.test(e)){var o=function(e){var r=e.match(s);if(null!=r){var t=p(r[1]);if(t.length>=2)return[t[0],t[1],t[2]]}throw new Error("Can't parse hsl color: ".concat(e))}(e);if(o.length>0)return u(o)}throw new Error("Invalid color: ".concat(e))}function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function v(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function w(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?v(Object(t),!0).forEach((function(r){k(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):v(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function k(e,r,t){return(r=function(e){var r=function(e,r){if("object"!==y(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!==y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"===y(r)?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function j(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(!e)return;if("string"==typeof e)return O(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,r)}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){l=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(l)throw a}}}}function O(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function S(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=Number.MAX_SAFE_INTEGER,o={name:"error",color:"#F00"};if(r.length<1)return o;var i=Object.values(m(e));if(i.length>2){var l,u=j(r);try{for(u.s();!(l=u.n()).done;){var c=l.value,f=q(i,c,!0);if(f<n&&(n=f,o.name=c[3],o.color="rgb(".concat(c[0],",").concat(c[1],",").concat(c[2],")")),0===f)break}}catch(e){u.e(e)}finally{u.f()}}for(var s=arguments.length,d=new Array(s>2?s-2:0),g=2;g<s;g++)d[g-2]=arguments[g];if((null==d?void 0:d.length)>0&&null!==(null==d?void 0:d.info)){var h=m(o.color),p=a(h);return w(w({},o),{},{hex:p,gap:Math.sqrt(n)})}return o}function M(e){return"white"===S(e,g).name}function E(e){return"black"===S(e,g).name}function I(e){return M(e)?"light":"dark"}function P(e){return S(e,h).name}function q(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t?Math.pow(r[0]-e[0],2)+Math.pow(r[1]-e[1],2)+Math.pow(r[2]-e[2],2):Math.sqrt(Math.pow(r[0]-e[0],2)+Math.pow(r[1]-e[1],2)+Math.pow(r[2]-e[2],2))}function A(e){if(f.test(e)){var r=i(e);if(r.length>0)return a(l(r))}throw new Error("Invalid color: ".concat(e))}return r})()));
|
|
2
2
|
//# sourceMappingURL=color-2-name.js.map
|
package/dist/color-2-name.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-2-name.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,IAExBD,EAAiB,WAAIC,GACtB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,gJC40B9D,QAj1BgC,CAC9B,CACE,IACA,IACA,IACA,SAEF,CACE,EACA,EACA,EACA,SAEF,CACE,IACA,EACA,EACA,OAEF,CACE,EACA,IACA,EACA,SAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,EACA,IACA,EACA,QAEF,CACE,IACA,EACA,IACA,UAEF,CACE,IACA,GACA,GACA,UAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,SAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,QAEF,CACE,GACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,EACA,QAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,EACA,EACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,aAEF,CACE,GACA,EACA,IACA,UAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,GACA,GACA,SAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,GACA,GACA,WAEF,CACE,EACA,EACA,IACA,YAEF,CACE,EACA,IACA,IACA,YAEF,CACE,IACA,IACA,GACA,iBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,EACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,EACA,IACA,eAEF,CACE,GACA,IACA,GACA,kBAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,GACA,IACA,iBAEF,CACE,GACA,GACA,GACA,iBAEF,CACE,EACA,IACA,IACA,iBAEF,CACE,IACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,YAEF,CACE,EACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,WAEF,CACE,GACA,IACA,IACA,cAEF,CACE,IACA,GACA,GACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,wBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,EACA,UAEF,CACE,IACA,IACA,IACA,oBAEF,CACE,EACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,mBAEF,CACE,EACA,IACA,IACA,qBAEF,CACE,GACA,IACA,IACA,mBAEF,CACE,IACA,GACA,IACA,mBAEF,CACE,GACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,eAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,EACA,SAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,GACA,EACA,aAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,QAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,GACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,GACA,cAEF,CACE,GACA,IACA,GACA,YAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,GACA,GACA,UAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,GACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,QAEF,CACE,EACA,IACA,IACA,eAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,OAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,YC9zBG,SAASC,EAAUD,GAExB,IAAME,EAA6C,MAAzBC,MAAMC,KAAKJ,GAAO,GAAcA,EAAMK,UAAU,GAAKL,EAM/E,GAAIE,EAASI,OAAS,EAAG,CACvB,GAAIJ,EAASI,OAAS,EACpB,OAnBC,SAA4BN,GAEjC,OAAOG,MAAMC,KAAKJ,GAAOO,KAAI,SAACC,GAAS,OAAMA,EAAIA,GAAGC,aAAa,GACnE,CAgBaC,CAAkBR,GAEzB,IAAMS,EAAMT,EAASU,MAAM,OAC3B,OAAe,MAAPD,EAAe,CAACA,EAAI,GAAGF,cAAeE,EAAI,GAAGF,cAAeE,EAAI,GAAGF,eAAiB,EAEhG,CAEA,MAAO,EACT,CAmBO,SAASI,EAAOC,GACrB,OAAOA,EAAKC,SAAS,IAAIC,SAAS,EAAG,IACvC,CAOO,SAASC,EAAaC,GAE3B,MACoB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AAI,GAC5BpD,KAAKuD,IAAIF,EAAK,GAAKD,EAAK,GAAI,GAC1BpD,KAAK+C,KACL/C,KAAKuD,IAAIF,EAAK,GAAKD,EAAK,GAAI,GAC1BpD,KAAKuD,IAAIF,EAAK,GAAKD,EAAK,GAAI,GAC5BpD,KAAKuD,IAAIF,EAAK,GAAKD,EAAK,GAAI,GAEpC,CASA,SAASI,EAAUC,GAEjB,GAAItE,EAAS+B,KAAKuC,GAAY,CAC5B,IAAM7E,EAAMI,EAASyE,GACrB,GAAI7E,EAAIZ,OAAS,EAEf,OAAOW,EADWW,EAAaV,GAGnC,CACA,MAAM,IAAIS,MAAM,kBAAD,OAAmBoE,GACpC,C","sources":["webpack://color2name/webpack/universalModuleDefinition","webpack://color2name/webpack/bootstrap","webpack://color2name/webpack/runtime/define property getters","webpack://color2name/webpack/runtime/hasOwnProperty shorthand","webpack://color2name/webpack/runtime/make namespace object","webpack://color2name/./src/data/colorSet.ts","webpack://color2name/./src/hex-utils.ts","webpack://color2name/./src/rgb-utils.ts","webpack://color2name/./src/hsl-utils.ts","webpack://color2name/./src/common.ts","webpack://color2name/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"color2name\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"color2name\"] = factory();\n\telse\n\t\troot[\"color2name\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const colorSet: RGBCOLORDEF[] = [\n [\n 255,\n 255,\n 255,\n 'white'\n ],\n [\n 0,\n 0,\n 0,\n 'black'\n ],\n [\n 255,\n 0,\n 0,\n 'red'\n ],\n [\n 0,\n 128,\n 0,\n 'green'\n ],\n [\n 0,\n 0,\n 255,\n 'blue'\n ],\n [\n 255,\n 165,\n 0,\n 'orange'\n ],\n [\n 128,\n 128,\n 128,\n 'grey'\n ],\n [\n 255,\n 255,\n 0,\n 'yellow'\n ],\n [\n 255,\n 0,\n 255,\n 'magenta'\n ],\n [\n 154,\n 205,\n 50,\n 'yellowgreen'\n ],\n [\n 192,\n 192,\n 192,\n 'silver'\n ],\n [\n 0,\n 255,\n 0,\n 'lime'\n ],\n [\n 128,\n 0,\n 128,\n 'purple'\n ],\n [\n 255,\n 99,\n 71,\n 'tomato'\n ],\n [\n 64,\n 224,\n 208,\n 'turquoise'\n ],\n [\n 255,\n 127,\n 80,\n 'coral'\n ],\n [\n 0,\n 255,\n 255,\n 'cyan'\n ],\n [\n 255,\n 250,\n 240,\n 'floralwhite'\n ],\n [\n 255,\n 192,\n 203,\n 'pink'\n ],\n [\n 34,\n 139,\n 34,\n 'forestgreen'\n ],\n [\n 245,\n 245,\n 220,\n 'beige'\n ],\n [\n 255,\n 0,\n 255,\n 'fuchsia'\n ],\n [\n 220,\n 220,\n 220,\n 'gainsboro'\n ],\n [\n 248,\n 248,\n 255,\n 'ghostwhite'\n ],\n [\n 255,\n 215,\n 0,\n 'gold'\n ],\n [\n 218,\n 165,\n 32,\n 'goldenrod'\n ],\n [\n 173,\n 255,\n 47,\n 'greenyellow'\n ],\n [\n 238,\n 130,\n 238,\n 'violet'\n ],\n [\n 245,\n 222,\n 179,\n 'wheat'\n ],\n [\n 245,\n 245,\n 245,\n 'whitesmoke'\n ],\n [\n 139,\n 0,\n 0,\n 'darkred'\n ],\n [\n 240,\n 248,\n 255,\n 'aliceblue'\n ],\n [\n 205,\n 92,\n 92,\n 'indianred'\n ],\n [\n 75,\n 0,\n 130,\n 'indigo'\n ],\n [\n 250,\n 235,\n 215,\n 'antiquewhite'\n ],\n [\n 0,\n 255,\n 255,\n 'aqua'\n ],\n [\n 127,\n 255,\n 212,\n 'aquamarine'\n ],\n [\n 240,\n 255,\n 255,\n 'azure'\n ],\n [\n 255,\n 228,\n 196,\n 'bisque'\n ],\n [\n 255,\n 235,\n 205,\n 'blanchedalmond'\n ],\n [\n 138,\n 43,\n 226,\n 'blueviolet'\n ],\n [\n 165,\n 42,\n 42,\n 'brown'\n ],\n [\n 222,\n 184,\n 135,\n 'burlywood'\n ],\n [\n 95,\n 158,\n 160,\n 'cadetblue'\n ],\n [\n 127,\n 255,\n 0,\n 'chartreuse'\n ],\n [\n 210,\n 105,\n 30,\n 'chocolate'\n ],\n [\n 100,\n 149,\n 237,\n 'cornflowerblue'\n ],\n [\n 255,\n 248,\n 220,\n 'cornsilk'\n ],\n [\n 220,\n 20,\n 60,\n 'crimson'\n ],\n [\n 0,\n 0,\n 139,\n 'darkblue'\n ],\n [\n 0,\n 139,\n 139,\n 'darkcyan'\n ],\n [\n 184,\n 134,\n 11,\n 'darkgoldenrod'\n ],\n [\n 169,\n 169,\n 169,\n 'darkgrey'\n ],\n [\n 0,\n 100,\n 0,\n 'darkgreen'\n ],\n [\n 189,\n 183,\n 107,\n 'darkkhaki'\n ],\n [\n 139,\n 0,\n 139,\n 'darkmagenta'\n ],\n [\n 85,\n 107,\n 47,\n 'darkolivegreen'\n ],\n [\n 255,\n 140,\n 0,\n 'darkorange'\n ],\n [\n 153,\n 50,\n 204,\n 'darkorchid'\n ],\n [\n 233,\n 150,\n 122,\n 'darksalmon'\n ],\n [\n 143,\n 188,\n 143,\n 'darkseagreen'\n ],\n [\n 72,\n 61,\n 139,\n 'darkslateblue'\n ],\n [\n 47,\n 79,\n 79,\n 'darkslategrey'\n ],\n [\n 0,\n 206,\n 209,\n 'darkturquoise'\n ],\n [\n 148,\n 0,\n 211,\n 'darkviolet'\n ],\n [\n 255,\n 20,\n 147,\n 'deeppink'\n ],\n [\n 0,\n 191,\n 255,\n 'deepskyblue'\n ],\n [\n 105,\n 105,\n 105,\n 'dimgrey'\n ],\n [\n 30,\n 144,\n 255,\n 'dodgerblue'\n ],\n [\n 178,\n 34,\n 34,\n 'firebrick'\n ],\n [\n 240,\n 255,\n 240,\n 'honeydew'\n ],\n [\n 255,\n 105,\n 180,\n 'hotpink'\n ],\n [\n 255,\n 255,\n 240,\n 'ivory'\n ],\n [\n 240,\n 230,\n 140,\n 'khaki'\n ],\n [\n 230,\n 230,\n 250,\n 'lavender'\n ],\n [\n 255,\n 240,\n 245,\n 'lavenderblush'\n ],\n [\n 124,\n 252,\n 0,\n 'lawngreen'\n ],\n [\n 255,\n 250,\n 205,\n 'lemonchiffon'\n ],\n [\n 173,\n 216,\n 230,\n 'lightblue'\n ],\n [\n 240,\n 128,\n 128,\n 'lightcoral'\n ],\n [\n 224,\n 255,\n 255,\n 'lightcyan'\n ],\n [\n 250,\n 250,\n 210,\n 'lightgoldenrodyellow'\n ],\n [\n 144,\n 238,\n 144,\n 'lightgreen'\n ],\n [\n 211,\n 211,\n 211,\n 'lightgrey'\n ],\n [\n 255,\n 182,\n 193,\n 'lightpink'\n ],\n [\n 255,\n 160,\n 122,\n 'lightsalmon'\n ],\n [\n 32,\n 178,\n 170,\n 'lightseagreen'\n ],\n [\n 135,\n 206,\n 250,\n 'lightskyblue'\n ],\n [\n 119,\n 136,\n 153,\n 'lightslategrey'\n ],\n [\n 176,\n 196,\n 222,\n 'lightsteelblue'\n ],\n [\n 255,\n 255,\n 224,\n 'lightyellow'\n ],\n [\n 50,\n 205,\n 50,\n 'limegreen'\n ],\n [\n 250,\n 240,\n 230,\n 'linen'\n ],\n [\n 128,\n 0,\n 0,\n 'maroon'\n ],\n [\n 102,\n 205,\n 170,\n 'mediumaquamarine'\n ],\n [\n 0,\n 0,\n 205,\n 'mediumblue'\n ],\n [\n 186,\n 85,\n 211,\n 'mediumorchid'\n ],\n [\n 147,\n 112,\n 219,\n 'mediumpurple'\n ],\n [\n 60,\n 179,\n 113,\n 'mediumseagreen'\n ],\n [\n 123,\n 104,\n 238,\n 'mediumslateblue'\n ],\n [\n 0,\n 250,\n 154,\n 'mediumspringgreen'\n ],\n [\n 72,\n 209,\n 204,\n 'mediumturquoise'\n ],\n [\n 199,\n 21,\n 133,\n 'mediumvioletred'\n ],\n [\n 25,\n 25,\n 112,\n 'midnightblue'\n ],\n [\n 245,\n 255,\n 250,\n 'mintcream'\n ],\n [\n 255,\n 228,\n 225,\n 'mistyrose'\n ],\n [\n 255,\n 228,\n 181,\n 'moccasin'\n ],\n [\n 255,\n 222,\n 173,\n 'navajowhite'\n ],\n [\n 0,\n 0,\n 128,\n 'navy'\n ],\n [\n 253,\n 245,\n 230,\n 'oldlace'\n ],\n [\n 128,\n 128,\n 0,\n 'olive'\n ],\n [\n 107,\n 142,\n 35,\n 'olivedrab'\n ],\n [\n 255,\n 69,\n 0,\n 'orangered'\n ],\n [\n 218,\n 112,\n 214,\n 'orchid'\n ],\n [\n 238,\n 232,\n 170,\n 'palegoldenrod'\n ],\n [\n 152,\n 251,\n 152,\n 'palegreen'\n ],\n [\n 175,\n 238,\n 238,\n 'paleturquoise'\n ],\n [\n 219,\n 112,\n 147,\n 'palevioletred'\n ],\n [\n 255,\n 239,\n 213,\n 'papayawhip'\n ],\n [\n 255,\n 218,\n 185,\n 'peachpuff'\n ],\n [\n 205,\n 133,\n 63,\n 'peru'\n ],\n [\n 221,\n 160,\n 221,\n 'plum'\n ],\n [\n 176,\n 224,\n 230,\n 'powderblue'\n ],\n [\n 102,\n 51,\n 153,\n 'rebeccapurple'\n ],\n [\n 188,\n 143,\n 143,\n 'rosybrown'\n ],\n [\n 65,\n 105,\n 225,\n 'royalblue'\n ],\n [\n 139,\n 69,\n 19,\n 'saddlebrown'\n ],\n [\n 250,\n 128,\n 114,\n 'salmon'\n ],\n [\n 244,\n 164,\n 96,\n 'sandybrown'\n ],\n [\n 46,\n 139,\n 87,\n 'seagreen'\n ],\n [\n 255,\n 245,\n 238,\n 'seashell'\n ],\n [\n 160,\n 82,\n 45,\n 'sienna'\n ],\n [\n 135,\n 206,\n 235,\n 'skyblue'\n ],\n [\n 106,\n 90,\n 205,\n 'slateblue'\n ],\n [\n 112,\n 128,\n 144,\n 'slategrey'\n ],\n [\n 255,\n 250,\n 250,\n 'snow'\n ],\n [\n 0,\n 255,\n 127,\n 'springgreen'\n ],\n [\n 70,\n 130,\n 180,\n 'steelblue'\n ],\n [\n 210,\n 180,\n 140,\n 'tan'\n ],\n [\n 0,\n 128,\n 128,\n 'teal'\n ],\n [\n 216,\n 191,\n 216,\n 'thistle'\n ]\n]\n\nexport default colorSet\n","/**\n * It returns an object with the hex values of the 3 digit hex color\n *\n * @param {string} value 3 digit hex\n * @return {string[]} 6 digit hex\n */\nexport function shortHexToLongHex (value: string): string[] {\n // split the string in to an array of digits then return an array that contains that digit doubled for each item\n return Array.from(value).map((v: string) => (v + v).toUpperCase())\n}\n\n/**\n *\n * @param value\n */\nexport function parseHex (value: colorString): string[] {\n // remove # at the beginning of the hex color\n const hexColor: string = (Array.from(value)[0] === '#') ? value.substring(1) : value\n\n /**\n * then if the number of digits is greater than 2 (so it's something like 123 or abc456)\n * breakdown the string into an object that contains the r g and b values in hex\n */\n if (hexColor.length > 2) {\n if (hexColor.length < 6) { // >=6 is the long notation\n return shortHexToLongHex(hexColor)\n } else {\n const hex = hexColor.match(/../g)\n return (hex != null) ? [hex[0].toUpperCase(), hex[1].toUpperCase(), hex[2].toUpperCase()] : []\n }\n }\n\n return []\n}\n\n/**\n * Convert a Hex color to rgb\n *\n * @param {string} hex without the \"#\"\n */\nexport function hexToRgb (hex: string[]): RGBVALUE | Error {\n // Extract the RGB values from the hex string\n if (hex.length >= 2) {\n return {\n r: parseInt(hex[0], 16),\n g: parseInt(hex[1], 16),\n b: parseInt(hex[2], 16)\n }\n }\n throw new Error(`Invalid Hex color: ${hex.join(', ')}`)\n}\n\nexport function toHex (int8: number): string {\n return int8.toString(16).padStart(2, '0')\n}\n\n/**\n* Convert rgb values to hex color\n*\n* @param {Object} rgb an object with the rgb values\n*/\nexport function valuesToHex (rgb: RGBVALUE): HEX {\n // Extract the RGB values from the hex string\n if (\n typeof rgb?.r === 'number' &&\n typeof rgb?.g === 'number' &&\n typeof rgb?.b === 'number') {\n return `#${toHex(rgb?.r)}${toHex(rgb?.g)}${toHex(rgb?.b)}`\n }\n return '#errorr'\n}\n","import { convertToInt8, rgbRegex, splitValues } from './common'\n\n/**\n *\n * @param rgbAsString - the rgb color as string to convert\n */\nexport function parseRgb (rgbAsString: string): string[] {\n const rgbvalue = rgbAsString.match(rgbRegex)\n if (rgbvalue != null) {\n const rgb: string[] = splitValues(rgbvalue[1])\n\n if (rgb.length >= 2) {\n return [\n rgb[0],\n rgb[1],\n rgb[2]\n ]\n }\n }\n throw new Error(`Can't parse rgb color: ${rgbAsString}`)\n}\n\n/**\n *\n * @param rgb - rgb value\n */\nexport function getRgbValues (rgb: string[]): RGBVALUE {\n if (rgb.length >= 2) {\n return {\n r: convertToInt8(rgb[0]),\n g: convertToInt8(rgb[1]),\n b: convertToInt8(rgb[2])\n }\n }\n throw new Error(`Invalid rgb color: ${rgb.join(', ')}`)\n}\n\nexport function valuesToRgb (rgb: RGBVALUE): string {\n return `rgb(${rgb.r},${rgb.g},${rgb.b})`\n}\n","import { convertToInt8, hslRegex, splitValues } from './common'\n\n/**\n *\n * @param value\n */\nexport function parseHsl (hslAsString: string): string[] {\n const hslvalue = hslAsString.match(hslRegex)\n if (hslvalue != null) {\n const hsl: string[] = splitValues(hslvalue[1])\n\n if (hsl.length >= 2) {\n return [\n hsl[0],\n hsl[1],\n hsl[2]\n ]\n }\n }\n throw new Error(`Can't parse hsl color: ${hslAsString}`)\n}\n\nexport function getHslValues (hsl: string[]): HSLVALUE {\n if (hsl.length >= 2) {\n return {\n h: convertToInt8(hsl[0]),\n s: convertToInt8(hsl[1], 100),\n l: convertToInt8(hsl[2], 100)\n }\n }\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n}\n\n/**\n * Parses an array of HSL values and the related RGB value\n *\n * @param hsl the HSL value to parse\n * @return {Object} rgb value\n */\nexport function hslToRgb (hsl: string[]): RGBVALUE {\n if (hsl === null || hsl.length < 2) {\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n }\n\n let {\n h,\n s,\n l\n } = getHslValues(hsl)\n\n // Must be fractions of 1\n s /= 100\n l /= 100\n\n const c = (1 - Math.abs(2 * l - 1)) * s\n const x = c * (1 - Math.abs((h / 60) % 2 - 1))\n const m = l - c / 2\n let r = 0\n let g = 0\n let b = 0\n\n if (h >= 0 && h < 60) {\n r = c; g = x; b = 0\n } else if (h >= 60 && h < 120) {\n r = x; g = c; b = 0\n } else if (h >= 120 && h < 180) {\n r = 0; g = c; b = x\n } else if (h >= 180 && h < 240) {\n r = 0; g = x; b = c\n } else if (h >= 240 && h < 300) {\n r = x; g = 0; b = c\n } else if (h >= 300 && h < 360) {\n r = c; g = 0; b = x\n }\n r = Math.round((r + m) * 255)\n g = Math.round((g + m) * 255)\n b = Math.round((b + m) * 255)\n\n return { r, g, b }\n}\n\nexport function valuesToHsl ({ r, g, b }: RGBVALUE): string {\n // Make r, g, and b fractions of 1\n r /= 255\n g /= 255\n b /= 255\n\n // Find greatest and smallest channel values\n const cmin = Math.min(r, g, b)\n const cmax = Math.max(r, g, b)\n const delta = cmax - cmin\n let h = 0\n let s = 0\n let l = 0\n\n // Calculate hue\n if (delta === 0) { // No difference\n h = 0\n } else if (cmax === r) { // Red is max\n h = ((g - b) / delta) % 6\n } else if (cmax === g) { // Green is max\n h = (b - r) / delta + 2\n } else { h = (r - g) / delta + 4 } // Blue is max\n\n h = Math.round(h * 60)\n\n // Make negative hues positive behind 360°\n if (h < 0) { h += 360 }\n\n // Calculate lightness\n l = (cmax + cmin) / 2\n\n // Calculate saturation\n s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1))\n\n // Multiply l and s by 100\n s = +(s * 100).toFixed(1)\n l = +(l * 100).toFixed(1)\n\n return `hsl(${h},${s}%,${l}%)`\n}\n","// Regular expressions to match different color formats\nimport { hexToRgb, parseHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\nimport { hslToRgb, parseHsl } from './hsl-utils'\n\nexport const MAXDISTANCE = 441.6729559300637\n\nexport const hexRegex = /^#([\\da-f]{6,}|[\\da-f]{3,})/i\nexport const rgbRegex = /^rgba?\\(([^)]+)\\)/i\nexport const hslRegex = /^hsla?\\(([^)]+)\\)/i\nexport const isNumeric = /^[0-9]*$/\n\n/**\n * This set is used in order to detect if the color is bright or dark\n *\n * @note the set has been corrected to get pure RGB values (eg. pure red, pure green) in the \"bright\" area\n */\nexport const BLACKANDWHITE: RGBCOLORDEF[] = [\n [\n 255,\n 255,\n 255,\n 'white'\n ],\n [\n 1,\n 1,\n 1,\n 'black'\n ]\n]\n\nexport const RGBSET: RGBCOLORDEF[] = [\n [\n 255,\n 0,\n 0,\n 'red'\n ],\n [\n 0,\n 255,\n 0,\n 'green'\n ],\n [\n 0,\n 0,\n 255,\n 'blue'\n ]\n]\n\n/**\n * split the content of rgb and hsl colors depending on the parsed value of the css property\n *\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#syntax\n *\n * @param rawValues\n */\nexport function splitValues (rawValues: string): string[] {\n if (rawValues.includes(',')) {\n return rawValues.split(/[,\\\\/]/).map(val => val.trim())\n }\n\n return rawValues.split(/[ \\\\/]/).map(val => val.trim()).filter(Boolean)\n}\n\n/**\n * takes a string with a css value that could be a number or percentage or an angle in degrees and returns the corresponding 8bit value\n *\n * @param value\n */\nexport function convertToInt8 (value: string, multiplier: number = 255): number {\n value = value.trim()\n if (isNumeric.test(value)) {\n // If the value is an int number return it as number\n return parseInt(value, 10)\n } else if (value.endsWith('%')) {\n // If the value is a percentage, divide it by 100 to get a value from 0 to 1\n // and then multiply it by 255 to get a value from 0 to 255\n return parseFloat(value) / 100 * multiplier\n } else if (value.endsWith('deg')) {\n // If the value is an angle in degrees, convert it to the 0-360 range\n // and then divide it by 360 to get a value from 0 to 1\n // and then multiply it by 255 to get a value from 0 to 255\n let angle = parseFloat(value)\n while (angle < 0) {\n angle += 360\n }\n while (angle > 360) {\n angle -= 360\n }\n return angle / 360 * multiplier\n } else {\n // If the value is not a percentage or an angle in degrees, it is invalid\n throw new Error(`Invalid value: ${value}`)\n }\n}\n\n/**\n * This function takes a string representing a color (color) and uses regular expressions to check if it matches any of the following formats: hex, hex+alpha, RGB, RGBA, HSL, or HSLA.\n * If the color string matches one of these formats, the function returns an object with the type of color and the value of the color.\n * If the color string does not match any of the formats, the function throws an error.\n *\n * @param colorString\n */\nexport function parseColor (colorString: colorString | string): RGBVALUE | Error {\n // Check if the color string matches any of the regular expressions\n if (hexRegex.test(colorString)) {\n const hex = parseHex(colorString as HEX)\n if (hex.length > 0) {\n return hexToRgb(hex)\n }\n } else if (rgbRegex.test(colorString)) {\n const rgb = parseRgb(colorString as RGB)\n if (rgb.length > 0) {\n return getRgbValues(rgb)\n }\n } else if (hslRegex.test(colorString)) {\n const hsl = parseHsl(colorString as HSL)\n if (hsl.length > 0) {\n return hslToRgb(hsl)\n }\n }\n\n // If the color string does not match any of the regular expressions, return an error\n throw new Error(`Invalid color: ${colorString}`)\n}\n","import colorSet from './data/colorSet'\nimport {BLACKANDWHITE, parseColor, rgbRegex, RGBSET} from './common'\nimport { valuesToHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\n\n/**\n * Given a color string it returns the closest corresponding name of the color\n *\n * @param color\n * @param colorSet\n * @param args\n * @param args.colors\n *\n * @return {string} the corresponding color name\n */\nfunction closest (\n color: colorString,\n set: RGBCOLORDEF[] | undefined = colorSet,\n ...args: any[ string | number ]\n): COLORDEF | COLORDEFINFO {\n let closestGap = Number.MAX_SAFE_INTEGER\n const closestColor: COLORDEF = { name: 'error', color: '#F00' }\n\n if (set.length < 1) {\n return closestColor\n }\n\n const rgbColorValues = Object.values(parseColor(color))\n if (rgbColorValues.length > 2) {\n for (const tested of set) {\n const gap = distance(rgbColorValues as RGBDEF, tested, true)\n if (gap < closestGap) {\n closestGap = gap\n closestColor.name = tested[3]\n closestColor.color = `rgb(${tested[0]},${tested[1]},${tested[2]})`\n }\n\n // TODO: add a minimum acceptable value in order to speed up the calculation. for example #ff0001 should return red since is very very close to red\n if (gap === 0) {\n break\n }\n }\n }\n\n if (args?.length > 0) {\n if (args?.info !== null) {\n const rgbValue = parseColor(closestColor.color)\n const hexValue = valuesToHex(rgbValue as RGBVALUE)\n return { ...closestColor, hex: hexValue, gap: Math.sqrt(closestGap) }\n }\n }\n\n return closestColor\n}\n\nfunction isLight (color: colorString): boolean {\n return closest(color, BLACKANDWHITE).name === 'white'\n}\nfunction isDark (color: colorString): boolean {\n return closest(color, BLACKANDWHITE).name === 'black'\n}\n\nfunction isLightOrDark (color: colorString): string {\n return isLight(color) ? 'light' : 'dark'\n}\n\nfunction closestRGB (color: colorString): string {\n return closest(color, RGBSET).name\n}\n\n/**\n * Compute the distance between the two RGB values\n * There are two modes:\n * fast = true -> the distance is calculated without using the Euclidean formula completely, it is reliable but its result is exponential\n * fast = false -> the distance is calculated with the Euclidean formula, its result is linear\n *\n * @param rgb1\n * @param rgb2\n * @param fast - whether to calculate the distance without computing the square root, the result will be\n */\nfunction distance (rgb1: RGBDEF, rgb2: RGBCOLORDEF, fast: boolean = false): number {\n return fast\n ? Math.pow(rgb2[0] - rgb1[0], 2) +\n Math.pow(rgb2[1] - rgb1[1], 2) +\n Math.pow(rgb2[2] - rgb1[2], 2)\n : Math.sqrt(\n Math.pow(rgb2[0] - rgb1[0], 2) +\n Math.pow(rgb2[1] - rgb1[1], 2) +\n Math.pow(rgb2[2] - rgb1[2], 2)\n )\n}\n\n/**\n * Given a color string it returns the hex representation\n *\n * @param rgbString\n *\n * @return {string} the corresponding color hex\n */\nfunction rgbToHex (rgbString: RGB): HEX | Error {\n // if is a rgb string\n if (rgbRegex.test(rgbString)) {\n const rgb = parseRgb(rgbString)\n if (rgb.length > 0) {\n const RgbValues = getRgbValues(rgb)\n return valuesToHex(RgbValues)\n }\n }\n throw new Error(`Invalid color: ${rgbString}`)\n}\n\nexport {\n colorSet,\n closest,\n rgbToHex,\n distance,\n isLight,\n isDark,\n isLightOrDark,\n closestRGB\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","parseHex","hexColor","Array","from","substring","length","map","v","toUpperCase","shortHexToLongHex","hex","match","toHex","int8","toString","padStart","valuesToHex","rgb","r","g","b","parseRgb","rgbAsString","rgbvalue","rgbRegex","splitValues","Error","getRgbValues","convertToInt8","join","hslToRgb","hsl","h","s","l","getHslValues","c","Math","abs","x","m","round","hexRegex","hslRegex","isNumeric","BLACKANDWHITE","RGBSET","rawValues","includes","split","val","trim","filter","Boolean","multiplier","test","parseInt","endsWith","parseFloat","angle","parseColor","colorString","hexToRgb","hslAsString","hslvalue","parseHsl","closest","color","set","colorSet","closestGap","Number","MAX_SAFE_INTEGER","closestColor","name","rgbColorValues","values","tested","gap","distance","args","info","rgbValue","hexValue","sqrt","isLight","isDark","isLightOrDark","closestRGB","rgb1","rgb2","fast","pow","rgbToHex","rgbString"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"color-2-name.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,IAExBD,EAAiB,WAAIC,GACtB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,gJC40B9D,QAj1BgC,CAC9B,CACE,IACA,IACA,IACA,SAEF,CACE,EACA,EACA,EACA,SAEF,CACE,IACA,EACA,EACA,OAEF,CACE,EACA,IACA,EACA,SAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,EACA,IACA,EACA,QAEF,CACE,IACA,EACA,IACA,UAEF,CACE,IACA,GACA,GACA,UAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,SAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,QAEF,CACE,GACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,EACA,QAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,EACA,EACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,aAEF,CACE,GACA,EACA,IACA,UAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,GACA,GACA,SAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,GACA,GACA,WAEF,CACE,EACA,EACA,IACA,YAEF,CACE,EACA,IACA,IACA,YAEF,CACE,IACA,IACA,GACA,iBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,EACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,EACA,IACA,eAEF,CACE,GACA,IACA,GACA,kBAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,GACA,IACA,iBAEF,CACE,GACA,GACA,GACA,iBAEF,CACE,EACA,IACA,IACA,iBAEF,CACE,IACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,YAEF,CACE,EACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,WAEF,CACE,GACA,IACA,IACA,cAEF,CACE,IACA,GACA,GACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,wBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,EACA,UAEF,CACE,IACA,IACA,IACA,oBAEF,CACE,EACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,mBAEF,CACE,EACA,IACA,IACA,qBAEF,CACE,GACA,IACA,IACA,mBAEF,CACE,IACA,GACA,IACA,mBAEF,CACE,GACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,eAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,EACA,SAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,GACA,EACA,aAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,QAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,GACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,eA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ACrB,GAAI7E,EAAIZ,OAAS,EAEf,OAAOW,EADWW,EAAaV,GAGnC,CACA,MAAM,IAAIS,MAAM,kBAAD,OAAmBoE,GACpC,C","sources":["webpack://color2name/webpack/universalModuleDefinition","webpack://color2name/webpack/bootstrap","webpack://color2name/webpack/runtime/define property getters","webpack://color2name/webpack/runtime/hasOwnProperty shorthand","webpack://color2name/webpack/runtime/make namespace object","webpack://color2name/./src/data/colorSet.ts","webpack://color2name/./src/hex-utils.ts","webpack://color2name/./src/rgb-utils.ts","webpack://color2name/./src/hsl-utils.ts","webpack://color2name/./src/common.ts","webpack://color2name/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"color2name\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"color2name\"] = factory();\n\telse\n\t\troot[\"color2name\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const colorSet: RGBCOLORDEF[] = [\n [\n 255,\n 255,\n 255,\n 'white'\n ],\n [\n 0,\n 0,\n 0,\n 'black'\n ],\n [\n 255,\n 0,\n 0,\n 'red'\n ],\n [\n 0,\n 128,\n 0,\n 'green'\n ],\n [\n 0,\n 0,\n 255,\n 'blue'\n ],\n [\n 255,\n 165,\n 0,\n 'orange'\n ],\n [\n 128,\n 128,\n 128,\n 'grey'\n ],\n [\n 255,\n 255,\n 0,\n 'yellow'\n ],\n [\n 255,\n 0,\n 255,\n 'magenta'\n ],\n [\n 154,\n 205,\n 50,\n 'yellowgreen'\n ],\n [\n 192,\n 192,\n 192,\n 'silver'\n ],\n [\n 0,\n 255,\n 0,\n 'lime'\n ],\n [\n 128,\n 0,\n 128,\n 'purple'\n ],\n [\n 255,\n 99,\n 71,\n 'tomato'\n ],\n [\n 64,\n 224,\n 208,\n 'turquoise'\n ],\n [\n 255,\n 127,\n 80,\n 'coral'\n ],\n [\n 0,\n 255,\n 255,\n 'cyan'\n ],\n [\n 255,\n 250,\n 240,\n 'floralwhite'\n ],\n [\n 255,\n 192,\n 203,\n 'pink'\n ],\n [\n 34,\n 139,\n 34,\n 'forestgreen'\n ],\n [\n 245,\n 245,\n 220,\n 'beige'\n ],\n [\n 255,\n 0,\n 255,\n 'fuchsia'\n ],\n [\n 220,\n 220,\n 220,\n 'gainsboro'\n ],\n [\n 248,\n 248,\n 255,\n 'ghostwhite'\n ],\n [\n 255,\n 215,\n 0,\n 'gold'\n ],\n [\n 218,\n 165,\n 32,\n 'goldenrod'\n ],\n [\n 173,\n 255,\n 47,\n 'greenyellow'\n ],\n [\n 238,\n 130,\n 238,\n 'violet'\n ],\n [\n 245,\n 222,\n 179,\n 'wheat'\n ],\n [\n 245,\n 245,\n 245,\n 'whitesmoke'\n ],\n [\n 139,\n 0,\n 0,\n 'darkred'\n ],\n [\n 240,\n 248,\n 255,\n 'aliceblue'\n ],\n [\n 205,\n 92,\n 92,\n 'indianred'\n ],\n [\n 75,\n 0,\n 130,\n 'indigo'\n ],\n [\n 250,\n 235,\n 215,\n 'antiquewhite'\n ],\n [\n 0,\n 255,\n 255,\n 'aqua'\n ],\n [\n 127,\n 255,\n 212,\n 'aquamarine'\n ],\n [\n 240,\n 255,\n 255,\n 'azure'\n ],\n [\n 255,\n 228,\n 196,\n 'bisque'\n ],\n [\n 255,\n 235,\n 205,\n 'blanchedalmond'\n ],\n [\n 138,\n 43,\n 226,\n 'blueviolet'\n ],\n [\n 165,\n 42,\n 42,\n 'brown'\n ],\n [\n 222,\n 184,\n 135,\n 'burlywood'\n ],\n [\n 95,\n 158,\n 160,\n 'cadetblue'\n ],\n [\n 127,\n 255,\n 0,\n 'chartreuse'\n ],\n [\n 210,\n 105,\n 30,\n 'chocolate'\n ],\n [\n 100,\n 149,\n 237,\n 'cornflowerblue'\n ],\n [\n 255,\n 248,\n 220,\n 'cornsilk'\n ],\n [\n 220,\n 20,\n 60,\n 'crimson'\n ],\n [\n 0,\n 0,\n 139,\n 'darkblue'\n ],\n [\n 0,\n 139,\n 139,\n 'darkcyan'\n ],\n [\n 184,\n 134,\n 11,\n 'darkgoldenrod'\n ],\n [\n 169,\n 169,\n 169,\n 'darkgrey'\n ],\n [\n 0,\n 100,\n 0,\n 'darkgreen'\n ],\n [\n 189,\n 183,\n 107,\n 'darkkhaki'\n ],\n [\n 139,\n 0,\n 139,\n 'darkmagenta'\n ],\n [\n 85,\n 107,\n 47,\n 'darkolivegreen'\n ],\n [\n 255,\n 140,\n 0,\n 'darkorange'\n ],\n [\n 153,\n 50,\n 204,\n 'darkorchid'\n ],\n [\n 233,\n 150,\n 122,\n 'darksalmon'\n ],\n [\n 143,\n 188,\n 143,\n 'darkseagreen'\n ],\n [\n 72,\n 61,\n 139,\n 'darkslateblue'\n ],\n [\n 47,\n 79,\n 79,\n 'darkslategrey'\n ],\n [\n 0,\n 206,\n 209,\n 'darkturquoise'\n ],\n [\n 148,\n 0,\n 211,\n 'darkviolet'\n ],\n [\n 255,\n 20,\n 147,\n 'deeppink'\n ],\n [\n 0,\n 191,\n 255,\n 'deepskyblue'\n ],\n [\n 105,\n 105,\n 105,\n 'dimgrey'\n ],\n [\n 30,\n 144,\n 255,\n 'dodgerblue'\n ],\n [\n 178,\n 34,\n 34,\n 'firebrick'\n ],\n [\n 240,\n 255,\n 240,\n 'honeydew'\n ],\n [\n 255,\n 105,\n 180,\n 'hotpink'\n ],\n [\n 255,\n 255,\n 240,\n 'ivory'\n ],\n [\n 240,\n 230,\n 140,\n 'khaki'\n ],\n [\n 230,\n 230,\n 250,\n 'lavender'\n ],\n [\n 255,\n 240,\n 245,\n 'lavenderblush'\n ],\n [\n 124,\n 252,\n 0,\n 'lawngreen'\n ],\n [\n 255,\n 250,\n 205,\n 'lemonchiffon'\n ],\n [\n 173,\n 216,\n 230,\n 'lightblue'\n ],\n [\n 240,\n 128,\n 128,\n 'lightcoral'\n ],\n [\n 224,\n 255,\n 255,\n 'lightcyan'\n ],\n [\n 250,\n 250,\n 210,\n 'lightgoldenrodyellow'\n ],\n [\n 144,\n 238,\n 144,\n 'lightgreen'\n ],\n [\n 211,\n 211,\n 211,\n 'lightgrey'\n ],\n [\n 255,\n 182,\n 193,\n 'lightpink'\n ],\n [\n 255,\n 160,\n 122,\n 'lightsalmon'\n ],\n [\n 32,\n 178,\n 170,\n 'lightseagreen'\n ],\n [\n 135,\n 206,\n 250,\n 'lightskyblue'\n ],\n [\n 119,\n 136,\n 153,\n 'lightslategrey'\n ],\n [\n 176,\n 196,\n 222,\n 'lightsteelblue'\n ],\n [\n 255,\n 255,\n 224,\n 'lightyellow'\n ],\n [\n 50,\n 205,\n 50,\n 'limegreen'\n ],\n [\n 250,\n 240,\n 230,\n 'linen'\n ],\n [\n 128,\n 0,\n 0,\n 'maroon'\n ],\n [\n 102,\n 205,\n 170,\n 'mediumaquamarine'\n ],\n [\n 0,\n 0,\n 205,\n 'mediumblue'\n ],\n [\n 186,\n 85,\n 211,\n 'mediumorchid'\n ],\n [\n 147,\n 112,\n 219,\n 'mediumpurple'\n ],\n [\n 60,\n 179,\n 113,\n 'mediumseagreen'\n ],\n [\n 123,\n 104,\n 238,\n 'mediumslateblue'\n ],\n [\n 0,\n 250,\n 154,\n 'mediumspringgreen'\n ],\n [\n 72,\n 209,\n 204,\n 'mediumturquoise'\n ],\n [\n 199,\n 21,\n 133,\n 'mediumvioletred'\n ],\n [\n 25,\n 25,\n 112,\n 'midnightblue'\n ],\n [\n 245,\n 255,\n 250,\n 'mintcream'\n ],\n [\n 255,\n 228,\n 225,\n 'mistyrose'\n ],\n [\n 255,\n 228,\n 181,\n 'moccasin'\n ],\n [\n 255,\n 222,\n 173,\n 'navajowhite'\n ],\n [\n 0,\n 0,\n 128,\n 'navy'\n ],\n [\n 253,\n 245,\n 230,\n 'oldlace'\n ],\n [\n 128,\n 128,\n 0,\n 'olive'\n ],\n [\n 107,\n 142,\n 35,\n 'olivedrab'\n ],\n [\n 255,\n 69,\n 0,\n 'orangered'\n ],\n [\n 218,\n 112,\n 214,\n 'orchid'\n ],\n [\n 238,\n 232,\n 170,\n 'palegoldenrod'\n ],\n [\n 152,\n 251,\n 152,\n 'palegreen'\n ],\n [\n 175,\n 238,\n 238,\n 'paleturquoise'\n ],\n [\n 219,\n 112,\n 147,\n 'palevioletred'\n ],\n [\n 255,\n 239,\n 213,\n 'papayawhip'\n ],\n [\n 255,\n 218,\n 185,\n 'peachpuff'\n ],\n [\n 205,\n 133,\n 63,\n 'peru'\n ],\n [\n 221,\n 160,\n 221,\n 'plum'\n ],\n [\n 176,\n 224,\n 230,\n 'powderblue'\n ],\n [\n 102,\n 51,\n 153,\n 'rebeccapurple'\n ],\n [\n 188,\n 143,\n 143,\n 'rosybrown'\n ],\n [\n 65,\n 105,\n 225,\n 'royalblue'\n ],\n [\n 139,\n 69,\n 19,\n 'saddlebrown'\n ],\n [\n 250,\n 128,\n 114,\n 'salmon'\n ],\n [\n 244,\n 164,\n 96,\n 'sandybrown'\n ],\n [\n 46,\n 139,\n 87,\n 'seagreen'\n ],\n [\n 255,\n 245,\n 238,\n 'seashell'\n ],\n [\n 160,\n 82,\n 45,\n 'sienna'\n ],\n [\n 135,\n 206,\n 235,\n 'skyblue'\n ],\n [\n 106,\n 90,\n 205,\n 'slateblue'\n ],\n [\n 112,\n 128,\n 144,\n 'slategrey'\n ],\n [\n 255,\n 250,\n 250,\n 'snow'\n ],\n [\n 0,\n 255,\n 127,\n 'springgreen'\n ],\n [\n 70,\n 130,\n 180,\n 'steelblue'\n ],\n [\n 210,\n 180,\n 140,\n 'tan'\n ],\n [\n 0,\n 128,\n 128,\n 'teal'\n ],\n [\n 216,\n 191,\n 216,\n 'thistle'\n ]\n]\n\nexport default colorSet\n","/**\n * It returns an object with the hex values of the 3 digit hex color\n *\n * @param {string} value 3 digit hex\n * @return {string[]} 6 digit hex\n */\nexport function shortHexToLongHex (value: string): string[] {\n // split the string in to an array of digits then return an array that contains that digit doubled for each item\n return Array.from(value).map((v: string) => (v + v).toUpperCase())\n}\n\n/**\n * Get the hex value of the color and convert it to an Object of R G And B values (still in hex format)\n *\n * @param value the string that contains the color in hex format\n *\n * @return {string[]} an array of 6 digit hex values in a triplet of R G and B (HEX format)\n */\nexport function parseHex (value: colorString): string[] {\n // remove # at the beginning of the hex color\n const hexColor: string = (Array.from(value)[0] === '#') ? value.substring(1) : value\n\n /**\n * then if the number of digits is greater than 2 (so it's something like 123 or abc456)\n * breakdown the string into an object that contains the r g and b values in hex\n */\n if (hexColor.length > 2) {\n if (hexColor.length < 6) { // >=6 is the long notation\n return shortHexToLongHex(hexColor)\n } else {\n const hex = hexColor.match(/../g)\n return (hex != null) ? [hex[0].toUpperCase(), hex[1].toUpperCase(), hex[2].toUpperCase()] : []\n }\n }\n\n return []\n}\n\n/**\n * Converts a Hex color to rgb\n *\n * @param {string} hex without the \"#\"\n *\n * @return {string} the rgb color values for the given hex color\n */\nexport function hexToRgb (hex: string[]): RGBVALUE | Error {\n // Extract the RGB values from the hex string\n if (hex.length >= 2) {\n return {\n r: parseInt(hex[0], 16),\n g: parseInt(hex[1], 16),\n b: parseInt(hex[2], 16)\n }\n }\n throw new Error(`Invalid Hex color: ${hex.join(', ')}`)\n}\n\n/**\n * Convert a INT8 value to HEX\n *\n * @param {number} int8 - the integer value to convert\n *\n * @return {string} the hex string\n */\nexport function toHex (int8: number): string {\n return int8.toString(16).padStart(2, '0')\n}\n\n/**\n* Convert rgb values to hex color\n*\n* @param {Object} rgb an object with the rgb values\n *\n * @return {string} the hex string\n*/\nexport function valuesToHex (rgb: RGBVALUE): HEX {\n // Extract the RGB values from the hex string\n if (\n typeof rgb?.r === 'number' &&\n typeof rgb?.g === 'number' &&\n typeof rgb?.b === 'number') {\n return `#${toHex(rgb?.r)}${toHex(rgb?.g)}${toHex(rgb?.b)}`\n }\n return '#errorr'\n}\n","import { convertToInt8, rgbRegex, splitValues } from './common'\n\n/**\n * Get the values of the rgb string\n *\n * @param rgbAsString - the rgb color as string split into values\n *\n * @return {Array} the values of the rgb string as Array of strings that represent the rgb color\n */\nexport function parseRgb (rgbAsString: string): string[] {\n const rgbvalue = rgbAsString.match(rgbRegex)\n if (rgbvalue != null) {\n const rgb: string[] = splitValues(rgbvalue[1])\n\n if (rgb.length >= 2) {\n return [\n rgb[0],\n rgb[1],\n rgb[2]\n ]\n }\n }\n throw new Error(`Can't parse rgb color: ${rgbAsString}`)\n}\n\n/**\n * This function takes an array of strings and returns and object with the rgb values converted into INT8 (0-255)\n *\n * @param {Array} rgb - rgb color as Array of strings\n *\n * @return {Object} an object that contains the r, g and b values as INT8\n */\nexport function getRgbValues (rgb: string[]): RGBVALUE {\n if (rgb.length >= 2) {\n return {\n r: convertToInt8(rgb[0]),\n g: convertToInt8(rgb[1]),\n b: convertToInt8(rgb[2])\n }\n }\n throw new Error(`Invalid rgb color: ${rgb.join(', ')}`)\n}\n\n/**\n * returns a string representation of the rgb values\n *\n * @param {Object} rgb the rgb color object\n *\n * @return {string} a string representation of the rgb values\n */\nexport function valuesToRgb (rgb: RGBVALUE): string {\n return `rgb(${rgb.r},${rgb.g},${rgb.b})`\n}\n","import { convertToInt8, hslRegex, splitValues } from './common'\n\n/**\n * Get the values of the hsl string\n *\n * @param {string} hslAsString - the valid hsl color string\n * @return {string[]} the values of the hsl string\n */\nexport function parseHsl (hslAsString: string): string[] {\n const hslvalue = hslAsString.match(hslRegex)\n if (hslvalue != null) {\n const hsl: string[] = splitValues(hslvalue[1])\n\n if (hsl.length >= 2) {\n return [\n hsl[0],\n hsl[1],\n hsl[2]\n ]\n }\n }\n throw new Error(`Can't parse hsl color: ${hslAsString}`)\n}\n\n/**\n * This function takes an array of strings and returns and object with the hsl values converted into INT8 (0-255)\n *\n * @param {string[]} hsl - the hsl values to parse from string to int8 values\n *\n */\nexport function getHslValues (hsl: string[]): HSLVALUE {\n if (hsl.length >= 2) {\n return {\n h: parseInt(hsl[0], 10),\n s: convertToInt8(hsl[1], 100),\n l: convertToInt8(hsl[2], 100)\n }\n }\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n}\n\n/**\n * Given the HSL color it convert the color into RGB\n *\n * @param {string[]} hsl the HSL value to parse\n * @return {Object} rgb value\n */\nexport function hslToRgb (hsl: string[]): RGBVALUE {\n if (hsl === null || hsl.length < 2) {\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n }\n\n let {\n h,\n s,\n l\n } = getHslValues(hsl)\n\n // Must be fractions of 1\n s /= 100\n l /= 100\n\n const c = (1 - Math.abs(2 * l - 1)) * s\n const x = c * (1 - Math.abs((h / 60) % 2 - 1))\n const m = l - c / 2\n let r = 0\n let g = 0\n let b = 0\n\n if (h >= 0 && h < 60) {\n r = c; g = x; b = 0\n } else if (h >= 60 && h < 120) {\n r = x; g = c; b = 0\n } else if (h >= 120 && h < 180) {\n r = 0; g = c; b = x\n } else if (h >= 180 && h < 240) {\n r = 0; g = x; b = c\n } else if (h >= 240 && h < 300) {\n r = x; g = 0; b = c\n } else if (h >= 300 && h < 360) {\n r = c; g = 0; b = x\n }\n r = Math.round((r + m) * 255)\n g = Math.round((g + m) * 255)\n b = Math.round((b + m) * 255)\n\n return { r, g, b }\n}\n\n/**\n * Given the RGB color it convert the color into HSL\n *\n * @param {number} r - red\n * @param {number} g - green\n * @param {number} b - blue\n *\n * @return {Object} hsl value\n */\nexport function valuesToHsl ({ r, g, b }: RGBVALUE): string {\n // Make r, g, and b fractions of 1\n r /= 255\n g /= 255\n b /= 255\n\n // Find greatest and smallest channel values\n const cmin = Math.min(r, g, b)\n const cmax = Math.max(r, g, b)\n const delta = cmax - cmin\n let h = 0\n let s = 0\n let l = 0\n\n // Calculate hue\n if (delta === 0) { // No difference\n h = 0\n } else if (cmax === r) { // Red is max\n h = ((g - b) / delta) % 6\n } else if (cmax === g) { // Green is max\n h = (b - r) / delta + 2\n } else { h = (r - g) / delta + 4 } // Blue is max\n\n h = Math.round(h * 60)\n\n // Make negative hues positive behind 360°\n if (h < 0) { h += 360 }\n\n // Calculate lightness\n l = (cmax + cmin) / 2\n\n // Calculate saturation\n s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1))\n\n // Multiply l and s by 100\n s = +(s * 100).toFixed(1)\n l = +(l * 100).toFixed(1)\n\n return `hsl(${h},${s}%,${l}%)`\n}\n","// Regular expressions to match different color formats\nimport { hexToRgb, parseHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\nimport { hslToRgb, parseHsl } from './hsl-utils'\n\n/** The maximum distance possible between colors */\nexport const MAXDISTANCE = 441.6729559300637\n\n/** Match hex colors */\nexport const hexRegex = /^#([\\da-f]{6,}|[\\da-f]{3,})/i\n/** Match rgb colors */\nexport const rgbRegex = /^rgba?\\(([^)]+)\\)/i\n/** Match hsl colors */\nexport const hslRegex = /^hsla?\\(([^)]+)\\)/i\n/** Match string with only numbers */\nexport const isNumeric = /^[0-9]*$/\n\n/**\n * This set is used in order to detect if the color is bright or dark\n *\n * @note the set has been corrected to get pure RGB values (eg. pure red, pure green) in the \"bright\" area\n */\nexport const BLACKANDWHITE: RGBCOLORDEF[] = [\n [255, 255, 255, 'white'],\n [1, 1, 1, 'black']\n]\n\n/**\n * This set is used in order to detect the nearest rgb color\n */\nexport const RGBSET: RGBCOLORDEF[] = [\n [255, 0, 0, 'red'],\n [0, 255, 0, 'green'],\n [0, 0, 255, 'blue']\n]\n\n/**\n * split the content of rgb and hsl colors depending on the parsed value of the css property\n *\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#syntax\n *\n * @param {string} rawValues - the value inside the rgb(.*) css color definition\n *\n * @return {Array} the array of rgb values finded inside the passed string\n */\nexport function splitValues (rawValues: string): string[] {\n if (rawValues.includes(',')) {\n return rawValues.split(/[,\\\\/]/).map(val => val.trim())\n }\n\n return rawValues.split(/[ \\\\/]/).map(val => val.trim()).filter(Boolean)\n}\n\n/**\n * Takes a string with a css value that could be a number or percentage or an angle in degrees and returns the corresponding 8bit value\n *\n * @param {string} value - a valid value for the css color definition (like 255, \"100%\", \"324deg\", etc)\n *\n * @return {string} the corresponding value in 8 bit format\n */\nexport function convertToInt8 (value: string, multiplier: number = 255): number {\n value = value.trim()\n if (isNumeric.test(value)) {\n // If the value is an int number return it as number\n return parseInt(value, 10)\n } else if (value.endsWith('%')) {\n // If the value is a percentage, divide it by 100 to get a value from 0 to 1\n // and then multiply it by 255 to get a value from 0 to 255\n return parseFloat(value) / 100 * multiplier\n } else if (value.endsWith('deg')) {\n // If the value is an angle in degrees, convert it to the 0-360 range\n // and then divide it by 360 to get a value from 0 to 1\n // and then multiply it by 255 to get a value from 0 to 255\n let angle = parseFloat(value)\n while (angle < 0) {\n angle += 360\n }\n while (angle > 360) {\n angle -= 360\n }\n return angle / 360 * multiplier\n } else {\n // If the value is not a percentage or an angle in degrees, it is invalid\n throw new Error(`Invalid value: ${value}`)\n }\n}\n\n/**\n * This function takes a string representing a color (color) and uses regular expressions to check if it matches any of the following formats: hex, hex+alpha, RGB, RGBA, HSL, or HSLA.\n * If the color string matches one of these formats, the function returns an object with the type of color and the value of the color.\n * If the color string does not match any of the formats, the function throws an error.\n *\n * @param {string} colorString - the color string to test and convert to rgb values\n *\n * @return {Object|Error} the object with rgb values of that color\n */\nexport function parseColor (colorString: colorString | string): RGBVALUE | Error {\n // Check if the color string matches any of the regular expressions\n if (hexRegex.test(colorString)) {\n const hex = parseHex(colorString as HEX)\n if (hex.length > 0) {\n return hexToRgb(hex)\n }\n } else if (rgbRegex.test(colorString)) {\n const rgb = parseRgb(colorString as RGB)\n if (rgb.length > 0) {\n return getRgbValues(rgb)\n }\n } else if (hslRegex.test(colorString)) {\n const hsl = parseHsl(colorString as HSL)\n if (hsl.length > 0) {\n return hslToRgb(hsl)\n }\n }\n\n // If the color string does not match any of the regular expressions, return an error\n throw new Error(`Invalid color: ${colorString}`)\n}\n","import colorSet from './data/colorSet'\nimport { BLACKANDWHITE, parseColor, rgbRegex, RGBSET } from './common'\nimport { valuesToHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\n\n/**\n * Given a color string it returns the closest corresponding name of the color.\n * Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.\n *\n * @param {string} color - the color string you want to find the closest color name\n * @param {Array} colorSet - the array of colors you want to find the closest color in. leave empty to use the default css color nameset\n * @param {Object} args - Optionally you can pass some additional arguments\n * @param args.info - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value) about the closest color.\n *\n * @return {Object} the closest color name and rgb value\n *\n */\nfunction closest (\n color: colorString,\n set: RGBCOLORDEF[] | undefined = colorSet,\n ...args: any[ string | number ]\n): COLORDEF | COLORDEFINFO {\n let closestGap = Number.MAX_SAFE_INTEGER\n const closestColor: COLORDEF = { name: 'error', color: '#F00' }\n\n if (set.length < 1) {\n return closestColor\n }\n\n const rgbColorValues = Object.values(parseColor(color))\n if (rgbColorValues.length > 2) {\n for (const tested of set) {\n const gap = distance(rgbColorValues as RGBDEF, tested, true)\n if (gap < closestGap) {\n closestGap = gap\n closestColor.name = tested[3]\n closestColor.color = `rgb(${tested[0]},${tested[1]},${tested[2]})`\n }\n\n // TODO: add a minimum acceptable value in order to speed up the calculation. for example #ff0001 should return red since is very very close to red\n if (gap === 0) {\n break\n }\n }\n }\n\n if (args?.length > 0) {\n if (args?.info !== null) {\n const rgbValue = parseColor(closestColor.color)\n const hexValue = valuesToHex(rgbValue as RGBVALUE)\n return { ...closestColor, hex: hexValue, gap: Math.sqrt(closestGap) }\n }\n }\n\n return closestColor\n}\n\n/**\n * Given a color returns if the color is light (by light is meant more mathematically closer to white)\n * @param {string} color - The color to check\n * @returns {boolean} true when the color is light, false otherwise\n */\nfunction isLight (color: colorString): boolean {\n return closest(color, BLACKANDWHITE).name === 'white'\n}\n\n/**\n * Given a color returns if the color is dark (by dark is meant more mathematically closer to black)\n * @param {string} color - The color to check\n * @returns {boolean} true when the color is dark, false otherwise\n */\nfunction isDark (color: colorString): boolean {\n return closest(color, BLACKANDWHITE).name === 'black'\n}\n\n/**\n * Given a color returns if the color is light or dark (by dark is meant more mathematically closer to black)\n * @param {string} color - The color to check\n * @returns {string} light when the color is close to white, dark otherwise\n */\nfunction isLightOrDark (color: colorString): string {\n return isLight(color) ? 'light' : 'dark'\n}\n\n/**\n * Given a color returns if the color is closer to \"red\", \"green\" or \"blue\".\n * @param {string} color - The color to check\n * @returns {string} light when the color is close to white, dark otherwise\n */\nfunction closestRGB (color: colorString): string {\n return closest(color, RGBSET).name\n}\n\n/**\n * Compute the distance between the two RGB values\n * There are two modes:\n * fast = true -> the distance is calculated without using the Euclidean formula completely, it is reliable but its result is exponential\n * fast = false -> the distance is calculated with the Euclidean formula, its result is linear\n *\n * @param rgb1 - The RGB value of the first color to compare\n * @param rgb2 - The RGB value of the second color to compare\n * @param fast - If you want to calculate the distance without calculating the square root, the result will be exponential otherwise is linear\n */\nfunction distance (rgb1: RGBDEF, rgb2: RGBCOLORDEF, fast: boolean = false): number {\n return fast\n ? Math.pow(rgb2[0] - rgb1[0], 2) +\n Math.pow(rgb2[1] - rgb1[1], 2) +\n Math.pow(rgb2[2] - rgb1[2], 2)\n : Math.sqrt(\n Math.pow(rgb2[0] - rgb1[0], 2) +\n Math.pow(rgb2[1] - rgb1[1], 2) +\n Math.pow(rgb2[2] - rgb1[2], 2)\n )\n}\n\n/**\n * Given a color string it returns the hex representation\n *\n * @param rgbString - the rgb color string to convert to hex\n *\n * @return {string} the corresponding color hex\n */\nfunction rgbToHex (rgbString: RGB): HEX | Error {\n // if is a rgb string\n if (rgbRegex.test(rgbString)) {\n const rgb = parseRgb(rgbString)\n if (rgb.length > 0) {\n const RgbValues = getRgbValues(rgb)\n return valuesToHex(RgbValues)\n }\n }\n throw new Error(`Invalid color: ${rgbString}`)\n}\n\nexport {\n colorSet,\n closest,\n rgbToHex,\n distance,\n isLight,\n isDark,\n isLightOrDark,\n closestRGB\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","parseHex","hexColor","Array","from","substring","length","map","v","toUpperCase","shortHexToLongHex","hex","match","toHex","int8","toString","padStart","valuesToHex","rgb","r","g","b","parseRgb","rgbAsString","rgbvalue","rgbRegex","splitValues","Error","getRgbValues","convertToInt8","join","hslToRgb","hsl","h","parseInt","s","l","getHslValues","c","Math","abs","x","m","round","hexRegex","hslRegex","isNumeric","BLACKANDWHITE","RGBSET","rawValues","includes","split","val","trim","filter","Boolean","multiplier","test","endsWith","parseFloat","angle","parseColor","colorString","hexToRgb","hslAsString","hslvalue","parseHsl","closest","color","set","colorSet","closestGap","Number","MAX_SAFE_INTEGER","closestColor","name","rgbColorValues","values","tested","gap","distance","args","info","rgbValue","hexValue","sqrt","isLight","isDark","isLightOrDark","closestRGB","rgb1","rgb2","fast","pow","rgbToHex","rgbString"],"sourceRoot":""}
|
package/dist/color-utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This function was the opposite of the name of the repo and returns the color of the colorSet given the name
|
|
3
3
|
*
|
|
4
|
-
* @param searchedColor -the name of the color to search for
|
|
5
|
-
* @param
|
|
4
|
+
* @param {string} searchedColor -the name of the color to search for
|
|
5
|
+
* @param {Array} set - the colorSet to search in
|
|
6
6
|
*/
|
|
7
7
|
declare function getColor(searchedColor: string, set?: RGBCOLORDEF[] | undefined): Object | Error;
|
|
8
8
|
export default getColor;
|
package/dist/common.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
/** The maximum distance possible between colors */
|
|
1
2
|
export declare const MAXDISTANCE = 441.6729559300637;
|
|
3
|
+
/** Match hex colors */
|
|
2
4
|
export declare const hexRegex: RegExp;
|
|
5
|
+
/** Match rgb colors */
|
|
3
6
|
export declare const rgbRegex: RegExp;
|
|
7
|
+
/** Match hsl colors */
|
|
4
8
|
export declare const hslRegex: RegExp;
|
|
9
|
+
/** Match string with only numbers */
|
|
5
10
|
export declare const isNumeric: RegExp;
|
|
6
11
|
/**
|
|
7
12
|
* This set is used in order to detect if the color is bright or dark
|
|
@@ -9,19 +14,26 @@ export declare const isNumeric: RegExp;
|
|
|
9
14
|
* @note the set has been corrected to get pure RGB values (eg. pure red, pure green) in the "bright" area
|
|
10
15
|
*/
|
|
11
16
|
export declare const BLACKANDWHITE: RGBCOLORDEF[];
|
|
17
|
+
/**
|
|
18
|
+
* This set is used in order to detect the nearest rgb color
|
|
19
|
+
*/
|
|
12
20
|
export declare const RGBSET: RGBCOLORDEF[];
|
|
13
21
|
/**
|
|
14
22
|
* split the content of rgb and hsl colors depending on the parsed value of the css property
|
|
15
23
|
*
|
|
16
24
|
* https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#syntax
|
|
17
25
|
*
|
|
18
|
-
* @param rawValues
|
|
26
|
+
* @param {string} rawValues - the value inside the rgb(.*) css color definition
|
|
27
|
+
*
|
|
28
|
+
* @return {Array} the array of rgb values finded inside the passed string
|
|
19
29
|
*/
|
|
20
30
|
export declare function splitValues(rawValues: string): string[];
|
|
21
31
|
/**
|
|
22
|
-
*
|
|
32
|
+
* Takes a string with a css value that could be a number or percentage or an angle in degrees and returns the corresponding 8bit value
|
|
23
33
|
*
|
|
24
|
-
* @param value
|
|
34
|
+
* @param {string} value - a valid value for the css color definition (like 255, "100%", "324deg", etc)
|
|
35
|
+
*
|
|
36
|
+
* @return {string} the corresponding value in 8 bit format
|
|
25
37
|
*/
|
|
26
38
|
export declare function convertToInt8(value: string, multiplier?: number): number;
|
|
27
39
|
/**
|
|
@@ -29,6 +41,8 @@ export declare function convertToInt8(value: string, multiplier?: number): numbe
|
|
|
29
41
|
* If the color string matches one of these formats, the function returns an object with the type of color and the value of the color.
|
|
30
42
|
* If the color string does not match any of the formats, the function throws an error.
|
|
31
43
|
*
|
|
32
|
-
* @param colorString
|
|
44
|
+
* @param {string} colorString - the color string to test and convert to rgb values
|
|
45
|
+
*
|
|
46
|
+
* @return {Object|Error} the object with rgb values of that color
|
|
33
47
|
*/
|
|
34
48
|
export declare function parseColor(colorString: colorString | string): RGBVALUE | Error;
|
package/dist/hex-utils.d.ts
CHANGED
|
@@ -6,20 +6,34 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function shortHexToLongHex(value: string): string[];
|
|
8
8
|
/**
|
|
9
|
+
* Get the hex value of the color and convert it to an Object of R G And B values (still in hex format)
|
|
9
10
|
*
|
|
10
|
-
* @param value
|
|
11
|
+
* @param value the string that contains the color in hex format
|
|
12
|
+
*
|
|
13
|
+
* @return {string[]} an array of 6 digit hex values in a triplet of R G and B (HEX format)
|
|
11
14
|
*/
|
|
12
15
|
export declare function parseHex(value: colorString): string[];
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* Converts a Hex color to rgb
|
|
15
18
|
*
|
|
16
19
|
* @param {string} hex without the "#"
|
|
20
|
+
*
|
|
21
|
+
* @return {string} the rgb color values for the given hex color
|
|
17
22
|
*/
|
|
18
23
|
export declare function hexToRgb(hex: string[]): RGBVALUE | Error;
|
|
24
|
+
/**
|
|
25
|
+
* Convert a INT8 value to HEX
|
|
26
|
+
*
|
|
27
|
+
* @param {number} int8 - the integer value to convert
|
|
28
|
+
*
|
|
29
|
+
* @return {string} the hex string
|
|
30
|
+
*/
|
|
19
31
|
export declare function toHex(int8: number): string;
|
|
20
32
|
/**
|
|
21
33
|
* Convert rgb values to hex color
|
|
22
34
|
*
|
|
23
35
|
* @param {Object} rgb an object with the rgb values
|
|
36
|
+
*
|
|
37
|
+
* @return {string} the hex string
|
|
24
38
|
*/
|
|
25
39
|
export declare function valuesToHex(rgb: RGBVALUE): HEX;
|
package/dist/hsl-utils.d.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Get the values of the hsl string
|
|
2
3
|
*
|
|
3
|
-
* @param
|
|
4
|
+
* @param {string} hslAsString - the valid hsl color string
|
|
5
|
+
* @return {string[]} the values of the hsl string
|
|
4
6
|
*/
|
|
5
7
|
export declare function parseHsl(hslAsString: string): string[];
|
|
8
|
+
/**
|
|
9
|
+
* This function takes an array of strings and returns and object with the hsl values converted into INT8 (0-255)
|
|
10
|
+
*
|
|
11
|
+
* @param {string[]} hsl - the hsl values to parse from string to int8 values
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
6
14
|
export declare function getHslValues(hsl: string[]): HSLVALUE;
|
|
7
15
|
/**
|
|
8
|
-
*
|
|
16
|
+
* Given the HSL color it convert the color into RGB
|
|
9
17
|
*
|
|
10
|
-
* @param hsl the HSL value to parse
|
|
18
|
+
* @param {string[]} hsl the HSL value to parse
|
|
11
19
|
* @return {Object} rgb value
|
|
12
20
|
*/
|
|
13
21
|
export declare function hslToRgb(hsl: string[]): RGBVALUE;
|
|
22
|
+
/**
|
|
23
|
+
* Given the RGB color it convert the color into HSL
|
|
24
|
+
*
|
|
25
|
+
* @param {number} r - red
|
|
26
|
+
* @param {number} g - green
|
|
27
|
+
* @param {number} b - blue
|
|
28
|
+
*
|
|
29
|
+
* @return {Object} hsl value
|
|
30
|
+
*/
|
|
14
31
|
export declare function valuesToHsl({ r, g, b }: RGBVALUE): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
import colorSet from './data/colorSet';
|
|
2
2
|
/**
|
|
3
|
-
* Given a color string it returns the closest corresponding name of the color
|
|
3
|
+
* Given a color string it returns the closest corresponding name of the color.
|
|
4
|
+
* Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.
|
|
4
5
|
*
|
|
5
|
-
* @param color
|
|
6
|
-
* @param colorSet
|
|
7
|
-
* @param args
|
|
8
|
-
* @param args.colors
|
|
6
|
+
* @param {string} color - the color string you want to find the closest color name
|
|
7
|
+
* @param {Array} colorSet - the array of colors you want to find the closest color in. leave empty to use the default css color nameset
|
|
8
|
+
* @param {Object} args - Optionally you can pass some additional arguments
|
|
9
|
+
* @param args.info - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value) about the closest color.
|
|
10
|
+
*
|
|
11
|
+
* @return {Object} the closest color name and rgb value
|
|
9
12
|
*
|
|
10
|
-
* @return {string} the corresponding color name
|
|
11
13
|
*/
|
|
12
14
|
declare function closest(color: colorString, set?: RGBCOLORDEF[] | undefined, ...args: any[string | number]): COLORDEF | COLORDEFINFO;
|
|
15
|
+
/**
|
|
16
|
+
* Given a color returns if the color is light (by light is meant more mathematically closer to white)
|
|
17
|
+
* @param {string} color - The color to check
|
|
18
|
+
* @returns {boolean} true when the color is light, false otherwise
|
|
19
|
+
*/
|
|
13
20
|
declare function isLight(color: colorString): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Given a color returns if the color is dark (by dark is meant more mathematically closer to black)
|
|
23
|
+
* @param {string} color - The color to check
|
|
24
|
+
* @returns {boolean} true when the color is dark, false otherwise
|
|
25
|
+
*/
|
|
14
26
|
declare function isDark(color: colorString): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Given a color returns if the color is light or dark (by dark is meant more mathematically closer to black)
|
|
29
|
+
* @param {string} color - The color to check
|
|
30
|
+
* @returns {string} light when the color is close to white, dark otherwise
|
|
31
|
+
*/
|
|
15
32
|
declare function isLightOrDark(color: colorString): string;
|
|
33
|
+
/**
|
|
34
|
+
* Given a color returns if the color is closer to "red", "green" or "blue".
|
|
35
|
+
* @param {string} color - The color to check
|
|
36
|
+
* @returns {string} light when the color is close to white, dark otherwise
|
|
37
|
+
*/
|
|
16
38
|
declare function closestRGB(color: colorString): string;
|
|
17
39
|
/**
|
|
18
40
|
* Compute the distance between the two RGB values
|
|
@@ -20,15 +42,15 @@ declare function closestRGB(color: colorString): string;
|
|
|
20
42
|
* fast = true -> the distance is calculated without using the Euclidean formula completely, it is reliable but its result is exponential
|
|
21
43
|
* fast = false -> the distance is calculated with the Euclidean formula, its result is linear
|
|
22
44
|
*
|
|
23
|
-
* @param rgb1
|
|
24
|
-
* @param rgb2
|
|
25
|
-
* @param fast -
|
|
45
|
+
* @param rgb1 - The RGB value of the first color to compare
|
|
46
|
+
* @param rgb2 - The RGB value of the second color to compare
|
|
47
|
+
* @param fast - If you want to calculate the distance without calculating the square root, the result will be exponential otherwise is linear
|
|
26
48
|
*/
|
|
27
49
|
declare function distance(rgb1: RGBDEF, rgb2: RGBCOLORDEF, fast?: boolean): number;
|
|
28
50
|
/**
|
|
29
51
|
* Given a color string it returns the hex representation
|
|
30
52
|
*
|
|
31
|
-
* @param rgbString
|
|
53
|
+
* @param rgbString - the rgb color string to convert to hex
|
|
32
54
|
*
|
|
33
55
|
* @return {string} the corresponding color hex
|
|
34
56
|
*/
|
package/dist/rgb-utils.d.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Get the values of the rgb string
|
|
2
3
|
*
|
|
3
|
-
* @param rgbAsString - the rgb color as string
|
|
4
|
+
* @param rgbAsString - the rgb color as string split into values
|
|
5
|
+
*
|
|
6
|
+
* @return {Array} the values of the rgb string as Array of strings that represent the rgb color
|
|
4
7
|
*/
|
|
5
8
|
export declare function parseRgb(rgbAsString: string): string[];
|
|
6
9
|
/**
|
|
10
|
+
* This function takes an array of strings and returns and object with the rgb values converted into INT8 (0-255)
|
|
11
|
+
*
|
|
12
|
+
* @param {Array} rgb - rgb color as Array of strings
|
|
7
13
|
*
|
|
8
|
-
* @
|
|
14
|
+
* @return {Object} an object that contains the r, g and b values as INT8
|
|
9
15
|
*/
|
|
10
16
|
export declare function getRgbValues(rgb: string[]): RGBVALUE;
|
|
17
|
+
/**
|
|
18
|
+
* returns a string representation of the rgb values
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} rgb the rgb color object
|
|
21
|
+
*
|
|
22
|
+
* @return {string} a string representation of the rgb values
|
|
23
|
+
*/
|
|
11
24
|
export declare function valuesToRgb(rgb: RGBVALUE): string;
|