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.27 to 0.2.28

2

build/culori.js

@@ -1006,3 +1006,3 @@ (function (global, factory) {

var interpolate = function interpolate(a, b, t, k) {
return a === undefined || b === undefined ? undefined : k === 'h' ? hue$2(a, b) : (1 - t) * a + t * b;
return a === undefined || b === undefined ? undefined : k === 'h' ? hue$2(a, b)(t) : (1 - t) * a + t * b;
};

@@ -1009,0 +1009,0 @@

@@ -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";function e(e){var a=e.h,r=e.s,n=e.v,t=e.alpha;(a%=360)<0&&(a+=360);var o=Math.abs(a/60%2-1),i=void 0;switch(Math.floor(a/60)){case 0:i={r:n,g:n*(1-r*o),b:n*(1-r)};break;case 1:i={r:n*(1-r*o),g:n,b:n*(1-r)};break;case 2:i={r:n*(1-r),g:n,b:n*(1-r*o)};break;case 3:i={r:n*(1-r),g:n*(1-r*o),b:n};break;case 4:i={r:n*(1-r*o),g:n*(1-r),b:n};break;case 5:i={r:n,g:n*(1-r),b:n*(1-r*o)}}return i.mode="rgb",void 0!==t&&(i.alpha=t),i}function a(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),h={mode:"hsv",s:0===o?0:1-i/o,v:o};return o-i!=0&&(h.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&&(h.alpha=t),h}var r=function(e){var a=e.l,r=e.a,n=e.b,t=e.alpha,o={mode:"lch",l:a,c:Math.sqrt(r*r+n*n),h:180*Math.atan2(n,r)/Math.PI};return o.h<0&&(o.h+=360),void 0!==t&&(o.alpha=t),o},n=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},t=Math.pow(29,3)/Math.pow(3,3),o=Math.pow(6,3)/Math.pow(29,3),i=function(e){return e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e},h=function(e){var a,r,n,h,l=function(e){var a=e.x,r=e.y,n=e.z;return{r:i(3.1338561*a-1.6168667*r-.4906146*n),g:i(-.9787684*a+1.9161415*r+.033454*n),b:i(.0719453*a-.2289914*r+1.4052427*n)}}((r=(a=e).l,n=a.a/500+(r+16)/116,h=(r+16)/116-a.b/200,{x:.9642*(Math.pow(n,3)>o?Math.pow(n,3):(116*n-16)/t),y:1*(r>8?Math.pow((r+16)/116,3):r/t),z:.82521*(Math.pow(h,3)>o?Math.pow(h,3):(116*h-16)/t)}));return l.mode="rgb",void 0!==e.alpha&&(l.alpha=e.alpha),l},l=function(e){return e<.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},u=Math.pow(29,3)/Math.pow(3,3),s=Math.pow(6,3)/Math.pow(29,3),d=function(e){return e>s?Math.cbrt(e):(u*e+16)/116},b=function(e){var a,r,n,t,o=function(e){var a=e.x,r=e.y,n=e.z,t=d(a/.9642),o=d(r/1);return{l:116*o-16,a:500*(t-o),b:200*(o-d(n/.82521))}}((r=(a=e).r,n=a.g,t=a.b,{x:.4360747*(r=l(r))+.3850649*(n=l(n))+.1430804*(t=l(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},c={hsi:{rgb:function(e){var a=e.h,r=e.s,n=e.i,t=e.alpha;a=(a<0?a+360:a)%360;var o=Math.abs(a/60%2-1),i=void 0;switch(Math.floor(a/60)){case 0:i={r:n*(1+r*(3/(2-o)-1)),g:n*(1+r*(3*(1-o)/(2-o)-1)),b:n*(1-r)};break;case 1:i={r:n*(1+r*(3*(1-o)/(2-o)-1)),g:n*(1+r*(3/(2-o)-1)),b:n*(1-r)};break;case 2:i={r:n*(1-r),g:n*(1+r*(3/(2-o)-1)),b:n*(1+r*(3*(1-o)/(2-o)-1))};break;case 3:i={r:n*(1-r),g:n*(1+r*(3*(1-o)/(2-o)-1)),b:n*(1+r*(3/(2-o)-1))};break;case 4:i={r:n*(1+r*(3*(1-o)/(2-o)-1)),g:n*(1-r),b:n*(1+r*(3/(2-o)-1))};break;case 5:i={r:n*(1+r*(3/(2-o)-1)),g:n*(1-r),b:n*(1+r*(3*(1-o)/(2-o)-1))}}return i.mode="rgb",void 0!==t&&(i.alpha=t),i}},hsl:{rgb:function(e){var a=e.h,r=e.s,n=e.l,t=e.alpha;a=(a<0?a+360:a)%360;var o=n+r*(n<.5?n:1-n),i=o-2*(o-n)*Math.abs(a/60%2-1),h=void 0;switch(Math.floor(a/60)){case 0:h={r:o,g:i,b:2*n-o};break;case 1:h={r:i,g:o,b:2*n-o};break;case 2:h={r:2*n-o,g:o,b:i};break;case 3:h={r:2*n-o,g:i,b:o};break;case 4:h={r:i,g:2*n-o,b:o};break;case 5:h={r:o,g:2*n-o,b:i}}return h.mode="rgb",void 0!==t&&(h.alpha=t),h}},hsv:{rgb:e},hwb:{rgb:function(a){var r=a.h,n=a.w,t=a.b,o=a.alpha;if(n+t>1){var i=n+t;n/=i,t/=i}return e({h:r,s:1===t?1:1-n/(1-t),v:1-t,alpha:o})}},lab:{lch:r,rgb:h},lch:{lab:n,rgb:function(e){return h(n(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),h={mode:"hsi",s:a+r+n===0?0:1-3*i/(a+r+n),i:(a+r+n)/3};return o-i!=0&&(h.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&&(h.alpha=t),h},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),h={mode:"hsl",s:o===i?0:(o-i)/(1-Math.abs(o+i-1)),l:.5*(o+i)};return o-i!=0&&(h.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&&(h.alpha=t),h},hsv:a,hwb:function(e){var r=a(e);if(void 0!==r){var n={mode:"hwb",w:(1-r.s)*r.v,b:1-r.v};return void 0!==r.h&&(n.h=r.h),void 0!==r.alpha&&(n.alpha=r.alpha),n}},lab:b,lch:function(e){return r(b(e))}}},g=function(e,a){return void 0!==e?e.mode===a?e:c[e.mode][a]?c[e.mode][a](e):"rgb"===mode?c[e.mode].rgb(e):c.rgb[a](c[e.mode].rgb(e)):void 0},p=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},v={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},f=function(e){return"string"==typeof e&&p(v[e.toLowerCase()],6)||void 0},m=(/([+-]?\d*\.?\d+(?:[eE][+-]?\d+)?)/+"").replace(/^\/|\/$/g,""),w=m+"%",y="(?:"+m+"%|"+m+")",M="(?:"+m+"(deg|grad|rad|turn)|"+m+")",k="\\s*,\\s*",x="\\s+",$=new RegExp("^rgba?\\(\\s*"+m+k+m+k+m+"\\s*(?:,\\s*"+y+"\\s*)?\\)$"),E=new RegExp("^rgba?\\(\\s*"+w+k+w+k+w+"\\s*(?:,\\s*"+y+"\\s*)?\\)$"),R=new RegExp("^rgba?\\(\\s*"+m+x+m+x+m+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),q=new RegExp("^rgba?\\(\\s*"+w+x+w+x+w+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),j=new RegExp("^hsla?\\(\\s*"+M+k+w+k+w+"\\s*(?:,\\s*"+y+"\\s*)?\\)$"),z=new RegExp("^hsla?\\(\\s*"+M+x+w+x+w+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),O=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,S=new RegExp("^hwb\\(\\s*"+M+x+w+x+w+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),I=new RegExp("^lab\\(\\s*"+m+x+m+x+m+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),P=new RegExp("^lch\\(\\s*"+m+x+m+x+M+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),H=new RegExp("^gray\\(\\s*"+m+"()()\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),N=function(e){var a;return(a=e.match(O))?p(parseInt(a[1],16),a[1].length):void 0},C=function(e){var a=void 0,r=void 0;if(a=e.match($)||e.match(R))r={mode:"rgb",r:a[1]/255,g:a[2]/255,b:a[3]/255};else{if(!(a=e.match(E)||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},L=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}},A=function(e){if("string"==typeof e){var a=e.match(j)||e.match(z);if(a){var r={mode:"hsl",h:void 0===a[3]?L(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}}},B=function(e){if("string"==typeof e){var a=e.match(S);if(a){var r={mode:"hwb",h:void 0===a[3]?L(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}}},D=function(e){return N(e)||C(e)||A(e)||f(e)||("transparent"===e?p(0,8):void 0)||B(e)||function(e){var a=void 0,r=void 0;if(a=e.match(I))r={mode:"lab",l:+a[1],a:+a[2],b:+a[3]};else{if(!(a=e.match(H)))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(P);if(a){var r={mode:"lch",l:+a[1],c:Math.max(0,+a[2]),h:void 0===a[5]?L(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)},F="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},G=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},J=function(e,a){return"object"!==(void 0===e?"undefined":F(e))?D(e):void 0===e.mode?G({},e,{mode:a}):e},K=function(e){return g(J(e,"rgb"),"rgb")},Q=function(e,a){return Math.round(e*(a=Math.pow(10,a)))/a};function T(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(void 0!==e)return"number"==typeof e?Q(e,a):"string"==typeof e?e:"object"===(void 0===e?"undefined":F(e))?Object.keys(e).reduce(function(a,r){return a[r]=T(e[r]),a},{}):void 0}var U=function(e){return Math.round(255*Math.max(0,Math.min(e,1)))},V={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"]},W=function(e,a){var r=V[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};var X=function(e,a,r,n){return void 0===e||void 0===a?void 0:"h"===n?function(e,a){var r=a-e;return r?function(e,a){return function(r){return e+r*a}}(e,r>180||r<-180?r-360*Math.round(r/360):r):e}(e,a):(1-r)*e+r*a},Y=function(e){return K(e)},Z=Object.freeze({hsl:function(e){return g(J(e,"hsl"),"hsl")},hsv:function(e){return g(J(e,"hsv"),"hsv")},hsi:function(e){return g(J(e,"hsi"),"hsi")},hwb:function(e){return g(J(e,"hwb"),"hwb")},rgb:K,lab:function(e){return g(J(e,"lab"),"lab")},lch:function(e){return g(J(e,"lch"),"lch")},css:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",r=K(e),n=U(r.r),t=U(r.g),o=U(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+", "+T(r.alpha,2)+")":void 0},convert:g,prepare:J,round:T,parse:D,parseNumber:p,parseNamed:f,parseHex:N,parseRgb:C,parseHsl:A,parseHwb:B,named:v,map:W,interpolate:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb";if(!(e.length<2)){var r=e.length-1,n=e.map(function(e){return g(J(e,a),a)});return function(e){var t=Math.min(Math.max(0,e),1)*r,o=Math.floor(t),i=n[o],h=n[o+1],l=t-o;return W({mode:a},function(e){return o===r?i[e]:X(i[e],h[e],l,e)})}}},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:Y});return Object.assign(Y,Z),Y});
!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";function e(e){var a=e.h,r=e.s,n=e.v,t=e.alpha;(a%=360)<0&&(a+=360);var o=Math.abs(a/60%2-1),i=void 0;switch(Math.floor(a/60)){case 0:i={r:n,g:n*(1-r*o),b:n*(1-r)};break;case 1:i={r:n*(1-r*o),g:n,b:n*(1-r)};break;case 2:i={r:n*(1-r),g:n,b:n*(1-r*o)};break;case 3:i={r:n*(1-r),g:n*(1-r*o),b:n};break;case 4:i={r:n*(1-r*o),g:n*(1-r),b:n};break;case 5:i={r:n,g:n*(1-r),b:n*(1-r*o)}}return i.mode="rgb",void 0!==t&&(i.alpha=t),i}function a(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),h={mode:"hsv",s:0===o?0:1-i/o,v:o};return o-i!=0&&(h.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&&(h.alpha=t),h}var r=function(e){var a=e.l,r=e.a,n=e.b,t=e.alpha,o={mode:"lch",l:a,c:Math.sqrt(r*r+n*n),h:180*Math.atan2(n,r)/Math.PI};return o.h<0&&(o.h+=360),void 0!==t&&(o.alpha=t),o},n=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},t=Math.pow(29,3)/Math.pow(3,3),o=Math.pow(6,3)/Math.pow(29,3),i=function(e){return e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e},h=function(e){var a,r,n,h,l=function(e){var a=e.x,r=e.y,n=e.z;return{r:i(3.1338561*a-1.6168667*r-.4906146*n),g:i(-.9787684*a+1.9161415*r+.033454*n),b:i(.0719453*a-.2289914*r+1.4052427*n)}}((r=(a=e).l,n=a.a/500+(r+16)/116,h=(r+16)/116-a.b/200,{x:.9642*(Math.pow(n,3)>o?Math.pow(n,3):(116*n-16)/t),y:1*(r>8?Math.pow((r+16)/116,3):r/t),z:.82521*(Math.pow(h,3)>o?Math.pow(h,3):(116*h-16)/t)}));return l.mode="rgb",void 0!==e.alpha&&(l.alpha=e.alpha),l},l=function(e){return e<.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},u=Math.pow(29,3)/Math.pow(3,3),s=Math.pow(6,3)/Math.pow(29,3),d=function(e){return e>s?Math.cbrt(e):(u*e+16)/116},b=function(e){var a,r,n,t,o=function(e){var a=e.x,r=e.y,n=e.z,t=d(a/.9642),o=d(r/1);return{l:116*o-16,a:500*(t-o),b:200*(o-d(n/.82521))}}((r=(a=e).r,n=a.g,t=a.b,{x:.4360747*(r=l(r))+.3850649*(n=l(n))+.1430804*(t=l(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},c={hsi:{rgb:function(e){var a=e.h,r=e.s,n=e.i,t=e.alpha;a=(a<0?a+360:a)%360;var o=Math.abs(a/60%2-1),i=void 0;switch(Math.floor(a/60)){case 0:i={r:n*(1+r*(3/(2-o)-1)),g:n*(1+r*(3*(1-o)/(2-o)-1)),b:n*(1-r)};break;case 1:i={r:n*(1+r*(3*(1-o)/(2-o)-1)),g:n*(1+r*(3/(2-o)-1)),b:n*(1-r)};break;case 2:i={r:n*(1-r),g:n*(1+r*(3/(2-o)-1)),b:n*(1+r*(3*(1-o)/(2-o)-1))};break;case 3:i={r:n*(1-r),g:n*(1+r*(3*(1-o)/(2-o)-1)),b:n*(1+r*(3/(2-o)-1))};break;case 4:i={r:n*(1+r*(3*(1-o)/(2-o)-1)),g:n*(1-r),b:n*(1+r*(3/(2-o)-1))};break;case 5:i={r:n*(1+r*(3/(2-o)-1)),g:n*(1-r),b:n*(1+r*(3*(1-o)/(2-o)-1))}}return i.mode="rgb",void 0!==t&&(i.alpha=t),i}},hsl:{rgb:function(e){var a=e.h,r=e.s,n=e.l,t=e.alpha;a=(a<0?a+360:a)%360;var o=n+r*(n<.5?n:1-n),i=o-2*(o-n)*Math.abs(a/60%2-1),h=void 0;switch(Math.floor(a/60)){case 0:h={r:o,g:i,b:2*n-o};break;case 1:h={r:i,g:o,b:2*n-o};break;case 2:h={r:2*n-o,g:o,b:i};break;case 3:h={r:2*n-o,g:i,b:o};break;case 4:h={r:i,g:2*n-o,b:o};break;case 5:h={r:o,g:2*n-o,b:i}}return h.mode="rgb",void 0!==t&&(h.alpha=t),h}},hsv:{rgb:e},hwb:{rgb:function(a){var r=a.h,n=a.w,t=a.b,o=a.alpha;if(n+t>1){var i=n+t;n/=i,t/=i}return e({h:r,s:1===t?1:1-n/(1-t),v:1-t,alpha:o})}},lab:{lch:r,rgb:h},lch:{lab:n,rgb:function(e){return h(n(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),h={mode:"hsi",s:a+r+n===0?0:1-3*i/(a+r+n),i:(a+r+n)/3};return o-i!=0&&(h.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&&(h.alpha=t),h},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),h={mode:"hsl",s:o===i?0:(o-i)/(1-Math.abs(o+i-1)),l:.5*(o+i)};return o-i!=0&&(h.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&&(h.alpha=t),h},hsv:a,hwb:function(e){var r=a(e);if(void 0!==r){var n={mode:"hwb",w:(1-r.s)*r.v,b:1-r.v};return void 0!==r.h&&(n.h=r.h),void 0!==r.alpha&&(n.alpha=r.alpha),n}},lab:b,lch:function(e){return r(b(e))}}},g=function(e,a){return void 0!==e?e.mode===a?e:c[e.mode][a]?c[e.mode][a](e):"rgb"===mode?c[e.mode].rgb(e):c.rgb[a](c[e.mode].rgb(e)):void 0},p=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},v={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},f=function(e){return"string"==typeof e&&p(v[e.toLowerCase()],6)||void 0},m=(/([+-]?\d*\.?\d+(?:[eE][+-]?\d+)?)/+"").replace(/^\/|\/$/g,""),w=m+"%",y="(?:"+m+"%|"+m+")",M="(?:"+m+"(deg|grad|rad|turn)|"+m+")",k="\\s*,\\s*",x="\\s+",$=new RegExp("^rgba?\\(\\s*"+m+k+m+k+m+"\\s*(?:,\\s*"+y+"\\s*)?\\)$"),E=new RegExp("^rgba?\\(\\s*"+w+k+w+k+w+"\\s*(?:,\\s*"+y+"\\s*)?\\)$"),R=new RegExp("^rgba?\\(\\s*"+m+x+m+x+m+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),q=new RegExp("^rgba?\\(\\s*"+w+x+w+x+w+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),j=new RegExp("^hsla?\\(\\s*"+M+k+w+k+w+"\\s*(?:,\\s*"+y+"\\s*)?\\)$"),z=new RegExp("^hsla?\\(\\s*"+M+x+w+x+w+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),O=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,S=new RegExp("^hwb\\(\\s*"+M+x+w+x+w+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),I=new RegExp("^lab\\(\\s*"+m+x+m+x+m+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),P=new RegExp("^lch\\(\\s*"+m+x+m+x+M+"\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),H=new RegExp("^gray\\(\\s*"+m+"()()\\s*(?:\\/\\s*"+y+"\\s*)?\\)$"),N=function(e){var a;return(a=e.match(O))?p(parseInt(a[1],16),a[1].length):void 0},C=function(e){var a=void 0,r=void 0;if(a=e.match($)||e.match(R))r={mode:"rgb",r:a[1]/255,g:a[2]/255,b:a[3]/255};else{if(!(a=e.match(E)||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},L=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}},A=function(e){if("string"==typeof e){var a=e.match(j)||e.match(z);if(a){var r={mode:"hsl",h:void 0===a[3]?L(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}}},B=function(e){if("string"==typeof e){var a=e.match(S);if(a){var r={mode:"hwb",h:void 0===a[3]?L(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}}},D=function(e){return N(e)||C(e)||A(e)||f(e)||("transparent"===e?p(0,8):void 0)||B(e)||function(e){var a=void 0,r=void 0;if(a=e.match(I))r={mode:"lab",l:+a[1],a:+a[2],b:+a[3]};else{if(!(a=e.match(H)))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(P);if(a){var r={mode:"lch",l:+a[1],c:Math.max(0,+a[2]),h:void 0===a[5]?L(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)},F="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},G=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},J=function(e,a){return"object"!==(void 0===e?"undefined":F(e))?D(e):void 0===e.mode?G({},e,{mode:a}):e},K=function(e){return g(J(e,"rgb"),"rgb")},Q=function(e,a){return Math.round(e*(a=Math.pow(10,a)))/a};function T(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(void 0!==e)return"number"==typeof e?Q(e,a):"string"==typeof e?e:"object"===(void 0===e?"undefined":F(e))?Object.keys(e).reduce(function(a,r){return a[r]=T(e[r]),a},{}):void 0}var U=function(e){return Math.round(255*Math.max(0,Math.min(e,1)))},V={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"]},W=function(e,a){var r=V[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};var X=function(e,a,r,n){return void 0===e||void 0===a?void 0:"h"===n?function(e,a){var r=a-e;return r?function(e,a){return function(r){return e+r*a}}(e,r>180||r<-180?r-360*Math.round(r/360):r):e}(e,a)(r):(1-r)*e+r*a},Y=function(e){return K(e)},Z=Object.freeze({hsl:function(e){return g(J(e,"hsl"),"hsl")},hsv:function(e){return g(J(e,"hsv"),"hsv")},hsi:function(e){return g(J(e,"hsi"),"hsi")},hwb:function(e){return g(J(e,"hwb"),"hwb")},rgb:K,lab:function(e){return g(J(e,"lab"),"lab")},lch:function(e){return g(J(e,"lch"),"lch")},css:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",r=K(e),n=U(r.r),t=U(r.g),o=U(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+", "+T(r.alpha,2)+")":void 0},convert:g,prepare:J,round:T,parse:D,parseNumber:p,parseNamed:f,parseHex:N,parseRgb:C,parseHsl:A,parseHwb:B,named:v,map:W,interpolate:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb";if(!(e.length<2)){var r=e.length-1,n=e.map(function(e){return g(J(e,a),a)});return function(e){var t=Math.min(Math.max(0,e),1)*r,o=Math.floor(t),i=n[o],h=n[o+1],l=t-o;return W({mode:a},function(e){return o===r?i[e]:X(i[e],h[e],l,e)})}}},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:Y});return Object.assign(Y,Z),Y});

@@ -1000,3 +1000,3 @@ // Based on: https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB

var interpolate = function interpolate(a, b, t, k) {
return a === undefined || b === undefined ? undefined : k === 'h' ? hue$2(a, b) : (1 - t) * a + t * b;
return a === undefined || b === undefined ? undefined : k === 'h' ? hue$2(a, b)(t) : (1 - t) * a + t * b;
};

@@ -1003,0 +1003,0 @@

{
"name": "culori",
"version": "0.2.27",
"version": "0.2.28",
"main": "build/culori.js",

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

@@ -18,3 +18,3 @@ import convert from './convert';

a === undefined || b === undefined ? undefined : (
k === 'h' ? hue(a,b) : (1 - t) * a + t * b
k === 'h' ? hue(a,b)(t) : (1 - t) * a + t * b
);

@@ -21,0 +21,0 @@

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