Socket
Socket
Sign inDemoInstall

culori

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

culori - npm Package Compare versions

Comparing version 0.2.34 to 0.2.35

6

build/culori.js

@@ -65,2 +65,4 @@ (function (global, factory) {

break;
default:
res = { r: i * (1 - s), g: i * (1 - s), b: i * (1 - s) };
}

@@ -98,2 +100,4 @@

res = { r: m1, g: 2 * l - m1, b: m2 };break;
default:
res = { r: 2 * l - m1, g: 2 * l - m1, b: 2 * l - m1 };
}

@@ -129,2 +133,4 @@ res.mode = 'rgb';

res = { r: v, g: v * (1 - s), b: v * (1 - s * f) };break;
default:
res = { r: v * (1 - s), g: v * (1 - s), b: v * (1 - s) };
}

@@ -131,0 +137,0 @@ res.mode = 'rgb';

2

build/culori.min.js

@@ -1,1 +0,1 @@

!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):e.culori=a()}(this,function(){"use strict";var e=function(e){return(e%=360)<0?e+360:e};function a(a){var r=a.h,n=a.s,t=a.v,o=a.alpha;r=e(r);var i=Math.abs(r/60%2-1),l=void 0;switch(Math.floor(r/60)){case 0:l={r:t,g:t*(1-n*i),b:t*(1-n)};break;case 1:l={r:t*(1-n*i),g:t,b:t*(1-n)};break;case 2:l={r:t*(1-n),g:t,b:t*(1-n*i)};break;case 3:l={r:t*(1-n),g:t*(1-n*i),b:t};break;case 4:l={r:t*(1-n*i),g:t*(1-n),b:t};break;case 5:l={r:t,g:t*(1-n),b:t*(1-n*i)}}return l.mode="rgb",void 0!==o&&(l.alpha=o),l}function r(e){var a=e.r,r=e.g,n=e.b,t=e.alpha,o=Math.max(a,r,n),i=Math.min(a,r,n),l={mode:"hsv",s:0===o?0:1-i/o,v:o};return o-i!=0&&(l.h=60*(o===a?(r-n)/(o-i)+6*(r<n):o===r?(n-a)/(o-i)+2:(a-r)/(o-i)+4)),void 0!==t&&(l.alpha=t),l}var n=function(a){var r=a.l,n=a.a,t=a.b,o=a.alpha,i={mode:"lch",l:r,c:Math.sqrt(n*n+t*t),h:e(180*Math.atan2(t,n)/Math.PI)};return void 0!==o&&(i.alpha=o),i},t=function(e){var a=e.l,r=e.c,n=e.h,t=e.alpha,o={mode:"lab",l:a,a:r*Math.cos(n/180*Math.PI),b:r*Math.sin(n/180*Math.PI)};return void 0!==t&&(o.alpha=t),o},o=Math.pow(29,3)/Math.pow(3,3),i=Math.pow(6,3)/Math.pow(29,3),l=function(e){return e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e},h=function(e){var a,r,n,t,h=function(e){var a=e.x,r=e.y,n=e.z;return{r:l(3.1338561*a-1.6168667*r-.4906146*n),g:l(-.9787684*a+1.9161415*r+.033454*n),b:l(.0719453*a-.2289914*r+1.4052427*n)}}((r=(a=e).l,n=a.a/500+(r+16)/116,t=(r+16)/116-a.b/200,{x:.9642*(Math.pow(n,3)>i?Math.pow(n,3):(116*n-16)/o),y:1*(r>8?Math.pow((r+16)/116,3):r/o),z:.82521*(Math.pow(t,3)>i?Math.pow(t,3):(116*t-16)/o)}));return h.mode="rgb",void 0!==e.alpha&&(h.alpha=e.alpha),h},u=function(e){return e<.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},s=Math.pow(29,3)/Math.pow(3,3),d=Math.pow(6,3)/Math.pow(29,3),b=function(e){return e>d?Math.cbrt(e):(s*e+16)/116},c=function(e){var a,r,n,t,o=function(e){var a=e.x,r=e.y,n=e.z,t=b(a/.9642),o=b(r/1);return{l:116*o-16,a:500*(t-o),b:200*(o-b(n/.82521))}}((r=(a=e).r,n=a.g,t=a.b,{x:.4360747*(r=u(r))+.3850649*(n=u(n))+.1430804*(t=u(t)),y:.2225045*r+.7168786*n+.0606169*t,z:.0139322*r+.0971045*n+.7141733*t}));return o.mode="lab",void 0!==e.alpha&&(o.alpha=e.alpha),o},g={hsi:{rgb:function(a){var r=a.h,n=a.s,t=a.i,o=a.alpha;r=e(r);var i=Math.abs(r/60%2-1),l=void 0;switch(Math.floor(r/60)){case 0:l={r:t*(1+n*(3/(2-i)-1)),g:t*(1+n*(3*(1-i)/(2-i)-1)),b:t*(1-n)};break;case 1:l={r:t*(1+n*(3*(1-i)/(2-i)-1)),g:t*(1+n*(3/(2-i)-1)),b:t*(1-n)};break;case 2:l={r:t*(1-n),g:t*(1+n*(3/(2-i)-1)),b:t*(1+n*(3*(1-i)/(2-i)-1))};break;case 3:l={r:t*(1-n),g:t*(1+n*(3*(1-i)/(2-i)-1)),b:t*(1+n*(3/(2-i)-1))};break;case 4:l={r:t*(1+n*(3*(1-i)/(2-i)-1)),g:t*(1-n),b:t*(1+n*(3/(2-i)-1))};break;case 5:l={r:t*(1+n*(3/(2-i)-1)),g:t*(1-n),b:t*(1+n*(3*(1-i)/(2-i)-1))}}return l.mode="rgb",void 0!==o&&(l.alpha=o),l}},hsl:{rgb:function(a){var r=a.h,n=a.s,t=a.l,o=a.alpha;r=e(r);var i=t+n*(t<.5?t:1-t),l=i-2*(i-t)*Math.abs(r/60%2-1),h=void 0;switch(Math.floor(r/60)){case 0:h={r:i,g:l,b:2*t-i};break;case 1:h={r:l,g:i,b:2*t-i};break;case 2:h={r:2*t-i,g:i,b:l};break;case 3:h={r:2*t-i,g:l,b:i};break;case 4:h={r:l,g:2*t-i,b:i};break;case 5:h={r:i,g:2*t-i,b:l}}return h.mode="rgb",void 0!==o&&(h.alpha=o),h}},hsv:{rgb:a},hwb:{rgb:function(e){var r=e.h,n=e.w,t=e.b,o=e.alpha;if(n+t>1){var i=n+t;n/=i,t/=i}return a({h:r,s:1===t?1:1-n/(1-t),v:1-t,alpha:o})}},lab:{lch:n,rgb:h},lch:{lab:t,rgb:function(e){return h(t(e))}},rgb:{hsi:function(e){var a=e.r,r=e.g,n=e.b,t=e.alpha,o=Math.max(a,r,n),i=Math.min(a,r,n),l={mode:"hsi",s:a+r+n===0?0:1-3*i/(a+r+n),i:(a+r+n)/3};return o-i!=0&&(l.h=60*(o===a?(r-n)/(o-i)+6*(r<n):o===r?(n-a)/(o-i)+2:(a-r)/(o-i)+4)),void 0!==t&&(l.alpha=t),l},hsl:function(e){var a=e.r,r=e.g,n=e.b,t=e.alpha,o=Math.max(a,r,n),i=Math.min(a,r,n),l={mode:"hsl",s:o===i?0:(o-i)/(1-Math.abs(o+i-1)),l:.5*(o+i)};return o-i!=0&&(l.h=60*(o===a?(r-n)/(o-i)+6*(r<n):o===r?(n-a)/(o-i)+2:(a-r)/(o-i)+4)),void 0!==t&&(l.alpha=t),l},hsv:r,hwb:function(e){var a=r(e);if(void 0!==a){var n={mode:"hwb",w:(1-a.s)*a.v,b:1-a.v};return void 0!==a.h&&(n.h=a.h),void 0!==a.alpha&&(n.alpha=a.alpha),n}},lab:c,lch:function(e){return n(c(e))}}},p=function(e,a){return void 0!==e?e.mode===a?e:g[e.mode][a]?g[e.mode][a](e):"rgb"===mode?g[e.mode].rgb(e):g.rgb[a](g[e.mode].rgb(e)):void 0},v=function(e,a){if("number"==typeof e)return 3===a?{mode:"rgb",r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|240&e)/255,b:(15&e|e<<4&240)/255}:4===a?{mode:"rgb",r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|240&e)/255,alpha:(15&e|e<<4&240)/255}:6===a?{mode:"rgb",r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}:8===a?{mode:"rgb",r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(255&e)/255}:void 0},f={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},m=function(e){return"string"==typeof e&&v(f[e.toLowerCase()],6)||void 0},w=(/([+-]?\d*\.?\d+(?:[eE][+-]?\d+)?)/+"").replace(/^\/|\/$/g,""),y=w+"%",M="(?:"+w+"%|"+w+")",k="(?:"+w+"(deg|grad|rad|turn)|"+w+")",x="\\s*,\\s*",$="\\s+",E=new RegExp("^rgba?\\(\\s*"+w+x+w+x+w+"\\s*(?:,\\s*"+M+"\\s*)?\\)$"),R=new RegExp("^rgba?\\(\\s*"+y+x+y+x+y+"\\s*(?:,\\s*"+M+"\\s*)?\\)$"),j=new RegExp("^rgba?\\(\\s*"+w+$+w+$+w+"\\s*(?:\\/\\s*"+M+"\\s*)?\\)$"),q=new RegExp("^rgba?\\(\\s*"+y+$+y+$+y+"\\s*(?:\\/\\s*"+M+"\\s*)?\\)$"),O=new RegExp("^hsla?\\(\\s*"+k+x+y+x+y+"\\s*(?:,\\s*"+M+"\\s*)?\\)$"),z=new RegExp("^hsla?\\(\\s*"+k+$+y+$+y+"\\s*(?:\\/\\s*"+M+"\\s*)?\\)$"),S=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,I=new RegExp("^hwb\\(\\s*"+k+$+y+$+y+"\\s*(?:\\/\\s*"+M+"\\s*)?\\)$"),P=new RegExp("^lab\\(\\s*"+w+$+w+$+w+"\\s*(?:\\/\\s*"+M+"\\s*)?\\)$"),H=new RegExp("^lch\\(\\s*"+w+$+w+$+k+"\\s*(?:\\/\\s*"+M+"\\s*)?\\)$"),N=new RegExp("^gray\\(\\s*"+w+"()()\\s*(?:\\/\\s*"+M+"\\s*)?\\)$"),C=function(e){var a;return(a=e.match(S))?v(parseInt(a[1],16),a[1].length):void 0},L=function(e){var a=void 0,r=void 0;if(a=e.match(E)||e.match(j))r={mode:"rgb",r:a[1]/255,g:a[2]/255,b:a[3]/255};else{if(!(a=e.match(R)||e.match(q)))return;r={mode:"rgb",r:a[1]/100,g:a[2]/100,b:a[3]/100}}return void 0!==a[4]?r.alpha=a[4]/100:void 0!==a[5]&&(r.alpha=+a[5]),r},A=function(e,a){switch(a){case"deg":return+e;case"rad":return e/Math.PI*180;case"grad":return e/10*9;case"turn":return 360*e}},B=function(e){if("string"==typeof e){var a=e.match(O)||e.match(z);if(a){var r={mode:"hsl",h:void 0===a[3]?A(a[1],a[2]):+a[3],s:Math.min(Math.max(0,a[4]/100),1),l:Math.min(Math.max(0,a[5]/100),1)};return void 0!==a[6]?r.alpha=a[6]/100:void 0!==a[7]&&(r.alpha=a[7]/255),r}}},D=function(e){if("string"==typeof e){var a=e.match(I);if(a){var r={mode:"hwb",h:void 0===a[3]?A(a[1],a[2]):+a[3],w:a[4]/100,b:a[5]/100};if(r.w+r.b>1){var n=r.w+r.b;r.w/=n,r.b/=n}return void 0!==a[6]?r.alpha=a[6]/100:void 0!==a[7]&&(r.alpha=a[7]/255),r}}},F=function(e){return C(e)||L(e)||B(e)||m(e)||("transparent"===e?v(0,8):void 0)||D(e)||function(e){var a=void 0,r=void 0;if(a=e.match(P))r={mode:"lab",l:+a[1],a:+a[2],b:+a[3]};else{if(!(a=e.match(N)))return;r={mode:"lab",l:+a[1],a:0,b:0}}return void 0!==a[4]?r.alpha=a[4]/100:void 0!==a[5]&&(r.alpha=+a[5]),r}(e)||function(e){var a=e.match(H);if(a){var r={mode:"lch",l:+a[1],c:Math.max(0,+a[2]),h:void 0===a[5]?A(a[3],a[4]):+a[5]};return void 0!==a[6]?r.alpha=a[6]/100:void 0!==a[7]&&(r.alpha=+a[7]),r}}(e)},G="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},J=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},K=function(e,a){return"object"!==(void 0===e?"undefined":G(e))?F(e):void 0===e.mode?J({},e,{mode:a}):e},Q=function(e){return p(K(e,"rgb"),"rgb")},T=function(e,a){return Math.round(e*(a=Math.pow(10,a)))/a};function U(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(void 0!==e)return"number"==typeof e?T(e,a):"string"==typeof e?e:"object"===(void 0===e?"undefined":G(e))?Object.keys(e).reduce(function(a,r){return a[r]=U(e[r]),a},{}):void 0}var V=function(e){return Math.round(255*Math.max(0,Math.min(e,1)))},W={rgb:["r","g","b","alpha"],hsl:["h","s","l","alpha"],hsv:["h","s","v","alpha"],hsi:["h","s","i","alpha"],lab:["l","a","b","alpha"],lch:["l","c","h","alpha"],hwb:["h","w","b","alpha"]},X=function(e,a){var r=W[e.mode].reduce(function(r,n){var t=a(n,e[n]);return void 0!==t&&(r[n]=t),r},{});return r.mode=e.mode,r},Y=function(e,a,r){return e+r*(a-e)},Z=function(e){return Q(e)},_=Object.freeze({hsl:function(e){return p(K(e,"hsl"),"hsl")},hsv:function(e){return p(K(e,"hsv"),"hsv")},hsi:function(e){return p(K(e,"hsi"),"hsi")},hwb:function(e){return p(K(e,"hwb"),"hwb")},rgb:Q,lab:function(e){return p(K(e,"lab"),"lab")},lch:function(e){return p(K(e,"lch"),"lch")},css:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",r=Q(e),n=V(r.r),t=V(r.g),o=V(r.b);return"hex"===a?"#"+(1<<24|n<<16|t<<8|o).toString(16).slice(1):"rgb"===a?void 0===r.alpha||1===r.alpha?"rgb("+n+", "+t+", "+o+")":"rgba("+n+", "+t+", "+o+", "+U(r.alpha,2)+")":void 0},convert:p,prepare:K,round:U,parse:F,parseNumber:v,parseNamed:m,parseHex:C,parseRgb:L,parseHsl:B,parseHwb:D,named:f,map:X,interpolate:function(a){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb";if(!(a.length<2)){var n=a.map(function(e){return p(K(e,r),r)});return function(a){if(1===(a=Math.min(Math.max(0,a),1)))return Object.assign({},n[n.length-1]);var t=a*(n.length-1),o=Math.floor(t),i=n[o],l=n[o+1],h=t-o;return X({mode:r},function(a){return("h"===a?function(a,r,n){return void 0!==a&&void 0!==r?(a=e(a),r=e(r),Math.abs(r-a)>180?e(Y(a,r-360*Math.sign(r-a),n)):Y(a,r,n)):void 0===a?r:a}:"alpha"===a?function(e,a,r){if(!(void 0===e&&void 0===a||void 0===e&&0===r||void 0===a&&1===r))return Y(void 0===e?1:e,void 0===a?1:a,r)}:function(e,a,r){return void 0!==e&&void 0!==a?Y(e,a,r):void 0===e?a:e})(i[a],l[a],h)})}}},swatches:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(a<2)return a<1?[e(0),e(1)]:[e(.5)];for(var r=[],n=0;n<a;n++)r.push(e(n/(a-1)));return r},default:Z});return Object.assign(Z,_),Z});
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):e.culori=a()}(this,function(){"use strict";var e=function(e){return(e%=360)<0?e+360:e};function a(a){var r=a.h,n=a.s,t=a.v,o=a.alpha;r=e(r);var i=Math.abs(r/60%2-1),l=void 0;switch(Math.floor(r/60)){case 0:l={r:t,g:t*(1-n*i),b:t*(1-n)};break;case 1:l={r:t*(1-n*i),g:t,b:t*(1-n)};break;case 2:l={r:t*(1-n),g:t,b:t*(1-n*i)};break;case 3:l={r:t*(1-n),g:t*(1-n*i),b:t};break;case 4:l={r:t*(1-n*i),g:t*(1-n),b:t};break;case 5:l={r:t,g:t*(1-n),b:t*(1-n*i)};break;default:l={r:t*(1-n),g:t*(1-n),b:t*(1-n)}}return l.mode="rgb",void 0!==o&&(l.alpha=o),l}function r(e){var a=e.r,r=e.g,n=e.b,t=e.alpha,o=Math.max(a,r,n),i=Math.min(a,r,n),l={mode:"hsv",s:0===o?0:1-i/o,v:o};return o-i!=0&&(l.h=60*(o===a?(r-n)/(o-i)+6*(r<n):o===r?(n-a)/(o-i)+2:(a-r)/(o-i)+4)),void 0!==t&&(l.alpha=t),l}var n=function(a){var r=a.l,n=a.a,t=a.b,o=a.alpha,i={mode:"lch",l:r,c:Math.sqrt(n*n+t*t),h:e(180*Math.atan2(t,n)/Math.PI)};return void 0!==o&&(i.alpha=o),i},t=function(e){var a=e.l,r=e.c,n=e.h,t=e.alpha,o={mode:"lab",l:a,a:r*Math.cos(n/180*Math.PI),b:r*Math.sin(n/180*Math.PI)};return void 0!==t&&(o.alpha=t),o},o=Math.pow(29,3)/Math.pow(3,3),i=Math.pow(6,3)/Math.pow(29,3),l=function(e){return e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e},h=function(e){var a,r,n,t,h=function(e){var a=e.x,r=e.y,n=e.z;return{r:l(3.1338561*a-1.6168667*r-.4906146*n),g:l(-.9787684*a+1.9161415*r+.033454*n),b:l(.0719453*a-.2289914*r+1.4052427*n)}}((r=(a=e).l,n=a.a/500+(r+16)/116,t=(r+16)/116-a.b/200,{x:.9642*(Math.pow(n,3)>i?Math.pow(n,3):(116*n-16)/o),y:1*(r>8?Math.pow((r+16)/116,3):r/o),z:.82521*(Math.pow(t,3)>i?Math.pow(t,3):(116*t-16)/o)}));return h.mode="rgb",void 0!==e.alpha&&(h.alpha=e.alpha),h},u=function(e){return e<.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},s=Math.pow(29,3)/Math.pow(3,3),d=Math.pow(6,3)/Math.pow(29,3),b=function(e){return e>d?Math.cbrt(e):(s*e+16)/116},c=function(e){var a,r,n,t,o=function(e){var a=e.x,r=e.y,n=e.z,t=b(a/.9642),o=b(r/1);return{l:116*o-16,a:500*(t-o),b:200*(o-b(n/.82521))}}((r=(a=e).r,n=a.g,t=a.b,{x:.4360747*(r=u(r))+.3850649*(n=u(n))+.1430804*(t=u(t)),y:.2225045*r+.7168786*n+.0606169*t,z:.0139322*r+.0971045*n+.7141733*t}));return o.mode="lab",void 0!==e.alpha&&(o.alpha=e.alpha),o},g={hsi:{rgb:function(a){var r=a.h,n=a.s,t=a.i,o=a.alpha;r=e(r);var i=Math.abs(r/60%2-1),l=void 0;switch(Math.floor(r/60)){case 0:l={r:t*(1+n*(3/(2-i)-1)),g:t*(1+n*(3*(1-i)/(2-i)-1)),b:t*(1-n)};break;case 1:l={r:t*(1+n*(3*(1-i)/(2-i)-1)),g:t*(1+n*(3/(2-i)-1)),b:t*(1-n)};break;case 2:l={r:t*(1-n),g:t*(1+n*(3/(2-i)-1)),b:t*(1+n*(3*(1-i)/(2-i)-1))};break;case 3:l={r:t*(1-n),g:t*(1+n*(3*(1-i)/(2-i)-1)),b:t*(1+n*(3/(2-i)-1))};break;case 4:l={r:t*(1+n*(3*(1-i)/(2-i)-1)),g:t*(1-n),b:t*(1+n*(3/(2-i)-1))};break;case 5:l={r:t*(1+n*(3/(2-i)-1)),g:t*(1-n),b:t*(1+n*(3*(1-i)/(2-i)-1))};break;default:l={r:t*(1-n),g:t*(1-n),b:t*(1-n)}}return l.mode="rgb",void 0!==o&&(l.alpha=o),l}},hsl:{rgb:function(a){var r=a.h,n=a.s,t=a.l,o=a.alpha;r=e(r);var i=t+n*(t<.5?t:1-t),l=i-2*(i-t)*Math.abs(r/60%2-1),h=void 0;switch(Math.floor(r/60)){case 0:h={r:i,g:l,b:2*t-i};break;case 1:h={r:l,g:i,b:2*t-i};break;case 2:h={r:2*t-i,g:i,b:l};break;case 3:h={r:2*t-i,g:l,b:i};break;case 4:h={r:l,g:2*t-i,b:i};break;case 5:h={r:i,g:2*t-i,b:l};break;default:h={r:2*t-i,g:2*t-i,b:2*t-i}}return h.mode="rgb",void 0!==o&&(h.alpha=o),h}},hsv:{rgb:a},hwb:{rgb:function(e){var r=e.h,n=e.w,t=e.b,o=e.alpha;if(n+t>1){var i=n+t;n/=i,t/=i}return a({h:r,s:1===t?1:1-n/(1-t),v:1-t,alpha:o})}},lab:{lch:n,rgb:h},lch:{lab:t,rgb:function(e){return h(t(e))}},rgb:{hsi:function(e){var a=e.r,r=e.g,n=e.b,t=e.alpha,o=Math.max(a,r,n),i=Math.min(a,r,n),l={mode:"hsi",s:a+r+n===0?0:1-3*i/(a+r+n),i:(a+r+n)/3};return o-i!=0&&(l.h=60*(o===a?(r-n)/(o-i)+6*(r<n):o===r?(n-a)/(o-i)+2:(a-r)/(o-i)+4)),void 0!==t&&(l.alpha=t),l},hsl:function(e){var a=e.r,r=e.g,n=e.b,t=e.alpha,o=Math.max(a,r,n),i=Math.min(a,r,n),l={mode:"hsl",s:o===i?0:(o-i)/(1-Math.abs(o+i-1)),l:.5*(o+i)};return o-i!=0&&(l.h=60*(o===a?(r-n)/(o-i)+6*(r<n):o===r?(n-a)/(o-i)+2:(a-r)/(o-i)+4)),void 0!==t&&(l.alpha=t),l},hsv:r,hwb:function(e){var a=r(e);if(void 0!==a){var n={mode:"hwb",w:(1-a.s)*a.v,b:1-a.v};return void 0!==a.h&&(n.h=a.h),void 0!==a.alpha&&(n.alpha=a.alpha),n}},lab:c,lch:function(e){return n(c(e))}}},p=function(e,a){return void 0!==e?e.mode===a?e:g[e.mode][a]?g[e.mode][a](e):"rgb"===mode?g[e.mode].rgb(e):g.rgb[a](g[e.mode].rgb(e)):void 0},v=function(e,a){if("number"==typeof e)return 3===a?{mode:"rgb",r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|240&e)/255,b:(15&e|e<<4&240)/255}:4===a?{mode:"rgb",r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|240&e)/255,alpha:(15&e|e<<4&240)/255}:6===a?{mode:"rgb",r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}:8===a?{mode:"rgb",r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(255&e)/255}:void 0},f={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},m=function(e){return"string"==typeof e&&v(f[e.toLowerCase()],6)||void 0},w=(/([+-]?\d*\.?\d+(?:[eE][+-]?\d+)?)/+"").replace(/^\/|\/$/g,""),y=w+"%",k="(?:"+w+"%|"+w+")",M="(?:"+w+"(deg|grad|rad|turn)|"+w+")",x="\\s*,\\s*",$="\\s+",E=new RegExp("^rgba?\\(\\s*"+w+x+w+x+w+"\\s*(?:,\\s*"+k+"\\s*)?\\)$"),R=new RegExp("^rgba?\\(\\s*"+y+x+y+x+y+"\\s*(?:,\\s*"+k+"\\s*)?\\)$"),j=new RegExp("^rgba?\\(\\s*"+w+$+w+$+w+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),q=new RegExp("^rgba?\\(\\s*"+y+$+y+$+y+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),O=new RegExp("^hsla?\\(\\s*"+M+x+y+x+y+"\\s*(?:,\\s*"+k+"\\s*)?\\)$"),z=new RegExp("^hsla?\\(\\s*"+M+$+y+$+y+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),S=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,I=new RegExp("^hwb\\(\\s*"+M+$+y+$+y+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),P=new RegExp("^lab\\(\\s*"+w+$+w+$+w+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),H=new RegExp("^lch\\(\\s*"+w+$+w+$+M+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),N=new RegExp("^gray\\(\\s*"+w+"()()\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),C=function(e){var a;return(a=e.match(S))?v(parseInt(a[1],16),a[1].length):void 0},L=function(e){var a=void 0,r=void 0;if(a=e.match(E)||e.match(j))r={mode:"rgb",r:a[1]/255,g:a[2]/255,b:a[3]/255};else{if(!(a=e.match(R)||e.match(q)))return;r={mode:"rgb",r:a[1]/100,g:a[2]/100,b:a[3]/100}}return void 0!==a[4]?r.alpha=a[4]/100:void 0!==a[5]&&(r.alpha=+a[5]),r},A=function(e,a){switch(a){case"deg":return+e;case"rad":return e/Math.PI*180;case"grad":return e/10*9;case"turn":return 360*e}},B=function(e){if("string"==typeof e){var a=e.match(O)||e.match(z);if(a){var r={mode:"hsl",h:void 0===a[3]?A(a[1],a[2]):+a[3],s:Math.min(Math.max(0,a[4]/100),1),l:Math.min(Math.max(0,a[5]/100),1)};return void 0!==a[6]?r.alpha=a[6]/100:void 0!==a[7]&&(r.alpha=a[7]/255),r}}},D=function(e){if("string"==typeof e){var a=e.match(I);if(a){var r={mode:"hwb",h:void 0===a[3]?A(a[1],a[2]):+a[3],w:a[4]/100,b:a[5]/100};if(r.w+r.b>1){var n=r.w+r.b;r.w/=n,r.b/=n}return void 0!==a[6]?r.alpha=a[6]/100:void 0!==a[7]&&(r.alpha=a[7]/255),r}}},F=function(e){return C(e)||L(e)||B(e)||m(e)||("transparent"===e?v(0,8):void 0)||D(e)||function(e){var a=void 0,r=void 0;if(a=e.match(P))r={mode:"lab",l:+a[1],a:+a[2],b:+a[3]};else{if(!(a=e.match(N)))return;r={mode:"lab",l:+a[1],a:0,b:0}}return void 0!==a[4]?r.alpha=a[4]/100:void 0!==a[5]&&(r.alpha=+a[5]),r}(e)||function(e){var a=e.match(H);if(a){var r={mode:"lch",l:+a[1],c:Math.max(0,+a[2]),h:void 0===a[5]?A(a[3],a[4]):+a[5]};return void 0!==a[6]?r.alpha=a[6]/100:void 0!==a[7]&&(r.alpha=+a[7]),r}}(e)},G="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},J=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},K=function(e,a){return"object"!==(void 0===e?"undefined":G(e))?F(e):void 0===e.mode?J({},e,{mode:a}):e},Q=function(e){return p(K(e,"rgb"),"rgb")},T=function(e,a){return Math.round(e*(a=Math.pow(10,a)))/a};function U(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(void 0!==e)return"number"==typeof e?T(e,a):"string"==typeof e?e:"object"===(void 0===e?"undefined":G(e))?Object.keys(e).reduce(function(a,r){return a[r]=U(e[r]),a},{}):void 0}var V=function(e){return Math.round(255*Math.max(0,Math.min(e,1)))},W={rgb:["r","g","b","alpha"],hsl:["h","s","l","alpha"],hsv:["h","s","v","alpha"],hsi:["h","s","i","alpha"],lab:["l","a","b","alpha"],lch:["l","c","h","alpha"],hwb:["h","w","b","alpha"]},X=function(e,a){var r=W[e.mode].reduce(function(r,n){var t=a(n,e[n]);return void 0!==t&&(r[n]=t),r},{});return r.mode=e.mode,r},Y=function(e,a,r){return e+r*(a-e)},Z=function(e){return Q(e)},_=Object.freeze({hsl:function(e){return p(K(e,"hsl"),"hsl")},hsv:function(e){return p(K(e,"hsv"),"hsv")},hsi:function(e){return p(K(e,"hsi"),"hsi")},hwb:function(e){return p(K(e,"hwb"),"hwb")},rgb:Q,lab:function(e){return p(K(e,"lab"),"lab")},lch:function(e){return p(K(e,"lch"),"lch")},css:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",r=Q(e),n=V(r.r),t=V(r.g),o=V(r.b);return"hex"===a?"#"+(1<<24|n<<16|t<<8|o).toString(16).slice(1):"rgb"===a?void 0===r.alpha||1===r.alpha?"rgb("+n+", "+t+", "+o+")":"rgba("+n+", "+t+", "+o+", "+U(r.alpha,2)+")":void 0},convert:p,prepare:K,round:U,parse:F,parseNumber:v,parseNamed:m,parseHex:C,parseRgb:L,parseHsl:B,parseHwb:D,named:f,map:X,interpolate:function(a){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb";if(!(a.length<2)){var n=a.map(function(e){return p(K(e,r),r)});return function(a){if(1===(a=Math.min(Math.max(0,a),1)))return Object.assign({},n[n.length-1]);var t=a*(n.length-1),o=Math.floor(t),i=n[o],l=n[o+1],h=t-o;return X({mode:r},function(a){return("h"===a?function(a,r,n){return void 0!==a&&void 0!==r?(a=e(a),r=e(r),Math.abs(r-a)>180?e(Y(a,r-360*Math.sign(r-a),n)):Y(a,r,n)):void 0===a?r:a}:"alpha"===a?function(e,a,r){if(!(void 0===e&&void 0===a||void 0===e&&0===r||void 0===a&&1===r))return Y(void 0===e?1:e,void 0===a?1:a,r)}:function(e,a,r){return void 0!==e&&void 0!==a?Y(e,a,r):void 0===e?a:e})(i[a],l[a],h)})}}},swatches:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(a<2)return a<1?[e(0),e(1)]:[e(.5)];for(var r=[],n=0;n<a;n++)r.push(e(n/(a-1)));return r},default:Z});return Object.assign(Z,_),Z});

@@ -59,2 +59,4 @@ var normalizeHue = (function (hue) {

break;
default:
res = { r: i * (1 - s), g: i * (1 - s), b: i * (1 - s) };
}

@@ -92,2 +94,4 @@

res = { r: m1, g: 2 * l - m1, b: m2 };break;
default:
res = { r: 2 * l - m1, g: 2 * l - m1, b: 2 * l - m1 };
}

@@ -123,2 +127,4 @@ res.mode = 'rgb';

res = { r: v, g: v * (1 - s), b: v * (1 - s * f) };break;
default:
res = { r: v * (1 - s), g: v * (1 - s), b: v * (1 - s) };
}

@@ -125,0 +131,0 @@ res.mode = 'rgb';

{
"name": "culori",
"version": "0.2.34",
"version": "0.2.35",
"main": "build/culori.js",

@@ -5,0 +5,0 @@ "module": "build/index.js",

@@ -52,2 +52,4 @@ import normalizeHue from '../util/normalizeHue';

break;
default:
res = { r: i * (1 - s), g: i * (1 - s), b: i * (1 - s) };
}

@@ -54,0 +56,0 @@

@@ -16,2 +16,3 @@ import normalizeHue from '../util/normalizeHue';

case 5: res = { r: m1, g: 2 * l - m1, b: m2 }; break;
default: res = { r: 2 * l - m1, g: 2 * l - m1, b: 2 * l - m1 };
}

@@ -18,0 +19,0 @@ res.mode = 'rgb';

@@ -16,2 +16,3 @@ import normalizeHue from '../util/normalizeHue';

case 5: res = { r: v, g: v * (1 - s), b: v * (1 - s * f) }; break;
default: res = { r: v * (1 - s), g: v * (1 - s), b: v * (1 - s) };
}

@@ -18,0 +19,0 @@ res.mode = 'rgb';

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc