Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.71 to 0.2.72

66

build/culori.js

@@ -377,26 +377,2 @@ (function (global, factory) {

var M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];
var degToRad = Math.PI / 180;
var linear = function linear(a, b, t) {
return a + t * (b - a);
};
var rgb$1 = converter('rgb');
var interpolateCubehelix = (function () {
var starthue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 300;
var endhue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -240;
var saturation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
var gamma = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
return function (t) {
return rgb$1({
mode: 'cubehelix',
h: linear(starthue, endhue, t),
l: Math.pow(t, gamma),
s: saturation
});
};
});
var samples = (function () {

@@ -1263,2 +1239,19 @@ var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;

var M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];
var degToRad = Math.PI / 180;
var radToDeg = 180 * Math.PI;
/*
This RGB to Cubehelix conversion is based on
Mike Bostock's work in d3-color.
Reference:
https://github.com/d3/d3-color/blob/master/src/cubehelix.js
*/
var x = M[1] * M[2] - M[3] * M[0];
var y = M[4] * M[3];
var z = M[4] * M[1];
var convertRgbToCubehelix = (function (_ref) {

@@ -1270,4 +1263,16 @@ var r = _ref.r,

var res = { mode: 'cubehelix' };
if (alpha !== undefind) res.alpha = alpha;
var l = (x * b + y * r - z * g) / (x + y - z);
var bl = b - l;
var k = (M[4] * (g - l) - M[2] * bl) / M[3];
var res = {
mode: 'cubehelix',
l: l,
s: Math.sqrt(k * k + bl * bl) / (M[4] * l * (1 - l))
};
if (res.s !== 0) res.h = normalizeHue(Math.atan2(k, bl) * radToDeg - 120);
if (alpha !== undefined) res.alpha = alpha;
return res;

@@ -1320,3 +1325,3 @@ });

interpolate: {
'h': interpolateHue(),
'h': interpolateHue(interpolateMethodLinear, false),
's': interpolateNumber(),

@@ -1338,3 +1343,3 @@ 'l': interpolateNumber(),

var rgb$2 = converter('rgb');
var rgb$1 = converter('rgb');
var lrgb = converter('lrgb');

@@ -1349,3 +1354,3 @@ var hsl = converter('hsl');

var culori = rgb$2;
var culori = rgb$1;

@@ -1357,3 +1362,3 @@ var methods = /*#__PURE__*/Object.freeze({

hwb: hwb$1,
rgb: rgb$2,
rgb: rgb$1,
lab: lab$1,

@@ -1373,3 +1378,2 @@ lch: lch$1,

interpolateMethodLinear: interpolateMethodLinear,
interpolateCubehelix: interpolateCubehelix,
samples: samples,

@@ -1376,0 +1380,0 @@ defineMode: defineMode,

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.culori=r()}(this,function(){"use strict";var e={},r={},a=[],n=function(n){e[n.mode]=Object.assign(e[n.mode]||{},n.output),Object.keys(n.input||{}).forEach(function(r){e[r]||(e[r]={}),e[r][n.mode]=n.input[r]}),r[n.mode]=n,(n.parsers||[]).forEach(function(e){return a.push(e)})},t=function(e){return r[e]},o=function(e){for(var r=void 0,n=0,t=a.length;n<t&&void 0===(r=a[n++](e)););return r},i="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},l=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},h=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"rgb";return function(a){return void 0!==(a=function(e,r){return"object"!==(void 0===e?"undefined":i(e))?o(e):void 0===e.mode?l({},e,{mode:r}):e}(a,r))?a.mode===r?a:e[a.mode][r]?e[a.mode][r](a):"rgb"===r?e[a.mode].rgb(a):e.rgb[r](e[a.mode].rgb(a)):void 0}},u=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;return function(r){return"number"==typeof r?function(e,r){return Math.round(e*(r=Math.pow(10,r)))/r}(r,e):r}},d=h("rgb"),s=u(2),b=function(e){return Math.round(255*Math.max(0,Math.min(e,1)))},g={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},c=function(e){return(e%=360)<0?e+360:e},p=function(e,r,a){return e+a*(r-e)},v=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p;return function(r,a){var n=a*(r.length-1),t=Math.floor(n),o=r[t],i=r[t+1];return void 0!==o&&void 0!==i?e(o,i,n-t):void 0===o?i:o}},f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function(a,n){var t=n*(a.length-1),o=Math.floor(t),i=a[o],l=a[o+1],h=t-o;return void 0!==i&&void 0!==l?(i=c(i),l=c(l),r&&Math.abs(l-i)>180?c(e(i,l-360*Math.sign(l-i),h)):e(i,l,h)):void 0===i?l:i}},m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p;return function(r,a){var n=a*(r.length-1),t=Math.floor(n),o=r[t],i=r[t+1],l=n-t;if(!(void 0===o&&void 0===i||void 0===o&&0===l||void 0===i&&1===l))return e(void 0===o?1:o,void 0===i?1:i,l)}},y=[-.14861,1.78277,-.29227,-.90649,1.97294,0],w=Math.PI/180,k=h("rgb"),M=function(e,r){if("number"==typeof e)return 3===r?{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===r?{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===r?{mode:"rgb",r:(e>>16&255)/255,g:(e>>8&255)/255,b:(255&e)/255}:8===r?{mode:"rgb",r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(255&e)/255}:void 0},x=(/([+-]?\d*\.?\d+(?:[eE][+-]?\d+)?)/+"").replace(/^\/|\/$/g,""),E=x+"%",$="(?:"+x+"%|"+x+")",j="(?:"+x+"(deg|grad|rad|turn)|"+x+")",q="\\s*,\\s*",R="\\s+",O=new RegExp("^rgba?\\(\\s*"+x+q+x+q+x+"\\s*(?:,\\s*"+$+"\\s*)?\\)$"),z=new RegExp("^rgba?\\(\\s*"+E+q+E+q+E+"\\s*(?:,\\s*"+$+"\\s*)?\\)$"),I=new RegExp("^rgba?\\(\\s*"+x+R+x+R+x+"\\s*(?:\\/\\s*"+$+"\\s*)?\\)$"),P=new RegExp("^rgba?\\(\\s*"+E+R+E+R+E+"\\s*(?:\\/\\s*"+$+"\\s*)?\\)$"),S=new RegExp("^hsla?\\(\\s*"+j+q+E+q+E+"\\s*(?:,\\s*"+$+"\\s*)?\\)$"),C=new RegExp("^hsla?\\(\\s*"+j+R+E+R+E+"\\s*(?:\\/\\s*"+$+"\\s*)?\\)$"),L=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,A=new RegExp("^hwb\\(\\s*"+j+R+E+R+E+"\\s*(?:\\/\\s*"+$+"\\s*)?\\)$"),D=new RegExp("^lab\\(\\s*"+x+R+x+R+x+"\\s*(?:\\/\\s*"+$+"\\s*)?\\)$"),H=new RegExp("^lch\\(\\s*"+x+R+x+R+j+"\\s*(?:\\/\\s*"+$+"\\s*)?\\)$"),N=new RegExp("^gray\\(\\s*"+x+"()()\\s*(?:\\/\\s*"+$+"\\s*)?\\)$"),B={mode:"rgb",channels:["r","g","b","alpha"],parsers:[function(e){var r;return(r=e.match(L))?M(parseInt(r[1],16),r[1].length):void 0},function(e){var r=void 0,a=void 0;if(r=e.match(O)||e.match(I))a={mode:"rgb",r:r[1]/255,g:r[2]/255,b:r[3]/255};else{if(!(r=e.match(z)||e.match(P)))return;a={mode:"rgb",r:r[1]/100,g:r[2]/100,b:r[3]/100}}return void 0!==r[4]?a.alpha=r[4]/100:void 0!==r[5]&&(a.alpha=+r[5]),a},function(e){return"string"==typeof e&&M(g[e.toLowerCase()],6)||void 0},function(e){return"transparent"===e?M(0,8):void 0}],interpolate:{r:v(),g:v(),b:v(),alpha:m()}},F=function(e){return e<.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},G=function(e){var r=e.r,a=e.g,n=e.b,t=e.alpha,o={mode:"lrgb",r:F(r),g:F(a),b:F(n)};return void 0!==t&&(o.alpha=t),o},J=function(e){return e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e},K=function(e){var r=e.r,a=e.g,n=e.b,t=e.alpha,o={mode:"rgb",r:J(r),g:J(a),b:J(n)};return void 0!==t&&(o.alpha=t),o},Q={mode:"lrgb",output:{rgb:K},input:{rgb:G},channels:["r","g","b","alpha"],interpolate:{r:v(),g:v(),b:v(),alpha:m()}};var T=function(e,r){switch(r){case"deg":return+e;case"rad":return e/Math.PI*180;case"grad":return e/10*9;case"turn":return 360*e}},U={mode:"hsl",output:{rgb:function(e){var r=e.h,a=e.s,n=e.l,t=e.alpha;r=c(r);var o=n+a*(n<.5?n:1-n),i=o-2*(o-n)*Math.abs(r/60%2-1),l=void 0;switch(Math.floor(r/60)){case 0:l={r:o,g:i,b:2*n-o};break;case 1:l={r:i,g:o,b:2*n-o};break;case 2:l={r:2*n-o,g:o,b:i};break;case 3:l={r:2*n-o,g:i,b:o};break;case 4:l={r:i,g:2*n-o,b:o};break;case 5:l={r:o,g:2*n-o,b:i};break;default:l={r:2*n-o,g:2*n-o,b:2*n-o}}return l.mode="rgb",void 0!==t&&(l.alpha=t),l}},input:{rgb:function(e){var r=e.r,a=e.g,n=e.b,t=e.alpha,o=Math.max(r,a,n),i=Math.min(r,a,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===r?(a-n)/(o-i)+6*(a<n):o===a?(n-r)/(o-i)+2:(r-a)/(o-i)+4)),void 0!==t&&(l.alpha=t),l}},channels:["h","s","l","alpha"],parsers:[function(e){if("string"==typeof e){var r=e.match(S)||e.match(C);if(r){var a={mode:"hsl",h:void 0===r[3]?T(r[1],r[2]):+r[3],s:Math.min(Math.max(0,r[4]/100),1),l:Math.min(Math.max(0,r[5]/100),1)};return void 0!==r[6]?a.alpha=r[6]/100:void 0!==r[7]&&(a.alpha=r[7]/255),a}}}],interpolate:{h:f(),s:v(),l:v(),alpha:m()}};function V(e){var r=e.h,a=e.s,n=e.v,t=e.alpha;r=c(r);var o=Math.abs(r/60%2-1),i=void 0;switch(Math.floor(r/60)){case 0:i={r:n,g:n*(1-a*o),b:n*(1-a)};break;case 1:i={r:n*(1-a*o),g:n,b:n*(1-a)};break;case 2:i={r:n*(1-a),g:n,b:n*(1-a*o)};break;case 3:i={r:n*(1-a),g:n*(1-a*o),b:n};break;case 4:i={r:n*(1-a*o),g:n*(1-a),b:n};break;case 5:i={r:n,g:n*(1-a),b:n*(1-a*o)};break;default:i={r:n*(1-a),g:n*(1-a),b:n*(1-a)}}return i.mode="rgb",void 0!==t&&(i.alpha=t),i}function W(e){var r=e.r,a=e.g,n=e.b,t=e.alpha,o=Math.max(r,a,n),i=Math.min(r,a,n),l={mode:"hsv",s:0===o?0:1-i/o,v:o};return o-i!=0&&(l.h=60*(o===r?(a-n)/(o-i)+6*(a<n):o===a?(n-r)/(o-i)+2:(r-a)/(o-i)+4)),void 0!==t&&(l.alpha=t),l}var X={mode:"hsv",output:{rgb:V},input:{rgb:W},channels:["h","s","v","alpha"],interpolate:{h:f(),s:v(),v:v(),alpha:m()}};var Y={mode:"hsi",output:{rgb:function(e){var r=e.h,a=e.s,n=e.i,t=e.alpha;r=c(r);var o=Math.abs(r/60%2-1),i=void 0;switch(Math.floor(r/60)){case 0:i={r:n*(1+a*(3/(2-o)-1)),g:n*(1+a*(3*(1-o)/(2-o)-1)),b:n*(1-a)};break;case 1:i={r:n*(1+a*(3*(1-o)/(2-o)-1)),g:n*(1+a*(3/(2-o)-1)),b:n*(1-a)};break;case 2:i={r:n*(1-a),g:n*(1+a*(3/(2-o)-1)),b:n*(1+a*(3*(1-o)/(2-o)-1))};break;case 3:i={r:n*(1-a),g:n*(1+a*(3*(1-o)/(2-o)-1)),b:n*(1+a*(3/(2-o)-1))};break;case 4:i={r:n*(1+a*(3*(1-o)/(2-o)-1)),g:n*(1-a),b:n*(1+a*(3/(2-o)-1))};break;case 5:i={r:n*(1+a*(3/(2-o)-1)),g:n*(1-a),b:n*(1+a*(3*(1-o)/(2-o)-1))};break;default:i={r:n*(1-a),g:n*(1-a),b:n*(1-a)}}return i.mode="rgb",void 0!==t&&(i.alpha=t),i}},input:{rgb:function(e){var r=e.r,a=e.g,n=e.b,t=e.alpha,o=Math.max(r,a,n),i=Math.min(r,a,n),l={mode:"hsi",s:r+a+n===0?0:1-3*i/(r+a+n),i:(r+a+n)/3};return o-i!=0&&(l.h=60*(o===r?(a-n)/(o-i)+6*(a<n):o===a?(n-r)/(o-i)+2:(r-a)/(o-i)+4)),void 0!==t&&(l.alpha=t),l}},channels:["h","s","i","alpha"],interpolate:{h:f(),s:v(),i:v(),alpha:m()}};var Z={mode:"hwb",output:{rgb:function(e){var r=e.h,a=e.w,n=e.b,t=e.alpha;if(a+n>1){var o=a+n;a/=o,n/=o}return V({h:r,s:1===n?1:1-a/(1-n),v:1-n,alpha:t})}},input:{rgb:function(e){var r=W(e);if(void 0!==r){var a={mode:"hwb",w:(1-r.s)*r.v,b:1-r.v};return void 0!==r.h&&(a.h=r.h),void 0!==r.alpha&&(a.alpha=r.alpha),a}}},channels:["h","w","b","alpha"],parsers:[function(e){if("string"==typeof e){var r=e.match(A);if(r){var a={mode:"hwb",h:void 0===r[3]?T(r[1],r[2]):+r[3],w:r[4]/100,b:r[5]/100};if(a.w+a.b>1){var n=a.w+a.b;a.w/=n,a.b/=n}return void 0!==r[6]?a.alpha=r[6]/100:void 0!==r[7]&&(a.alpha=r[7]/255),a}}}],interpolate:{h:f(),w:v(),b:v(),alpha:m()}},_=Math.pow(29,3)/Math.pow(3,3),ee=Math.pow(6,3)/Math.pow(29,3),re=function(e){return Math.pow(e,3)>ee?Math.pow(e,3):(116*e-16)/_},ae=function(e){var r,a,n,t,o,i=function(e){var r=e.x,a=e.y,n=e.z;return K({r:3.1338561*r-1.6168667*a-.4906146*n,g:-.9787684*r+1.9161415*a+.033454*n,b:.0719453*r-.2289914*a+1.4052427*n})}((a=(r=e).l,n=r.a,o=(t=(a+16)/116)-r.b/200,{x:.96422*re(n/500+t),y:1*re(t),z:.82521*re(o)}));return i.mode="rgb",void 0!==e.alpha&&(i.alpha=e.alpha),i},ne=function(e){return e>ee?Math.cbrt(e):(_*e+16)/116},te=function(e){var r,a,n,t,o,i,l=(r=function(e){var r=G(e),a=r.r,n=r.g,t=r.b;return{x:.4360747*a+.3850649*n+.1430804*t,y:.2225045*a+.7168786*n+.0606169*t,z:.0139322*a+.0971045*n+.7141733*t}}(e),a=r.x,n=r.y,t=r.z,o=ne(a/.96422),{mode:"lab",l:116*(i=ne(n/1))-16,a:500*(o-i),b:200*(i-ne(t/.82521))});return e.r===e.b===e.g&&(l.a=l.b=0),void 0!==e.alpha&&(l.alpha=e.alpha),l},oe={mode:"lab",output:{rgb:ae},input:{rgb:te},channels:["l","a","b","alpha"],parsers:[function(e){var r=void 0,a=void 0;if(r=e.match(D))a={mode:"lab",l:+r[1],a:+r[2],b:+r[3]};else{if(!(r=e.match(N)))return;a={mode:"lab",l:+r[1],a:0,b:0}}return void 0!==r[4]?a.alpha=r[4]/100:void 0!==r[5]&&(a.alpha=+r[5]),a}],interpolate:{l:v(),a:v(),b:v(),alpha:m()}},ie=function(e){var r=e.l,a=e.a,n=e.b,t=e.alpha,o=Math.sqrt(a*a+n*n),i={mode:"lch",l:r,c:o};return o&&(i.h=c(180*Math.atan2(n,a)/Math.PI)),void 0!==t&&(i.alpha=t),i},le=function(e){var r=e.l,a=e.c,n=e.h,t=e.alpha,o={mode:"lab",l:r,a:0===a?0:a*Math.cos(n/180*Math.PI),b:0===a?0:a*Math.sin(n/180*Math.PI)};return void 0!==t&&(o.alpha=t),o},he={mode:"lch",output:{lab:le,rgb:function(e){return ae(le(e))}},input:{rgb:function(e){return ie(te(e))},lch:ie},channels:["l","c","h","alpha"],parsers:[function(e){var r=e.match(H);if(r){var a={mode:"lch",l:+r[1],c:Math.max(0,+r[2]),h:void 0===r[5]?T(r[3],r[4]):+r[5]};return void 0!==r[6]?a.alpha=r[6]/100:void 0!==r[7]&&(a.alpha=+r[7]),a}}],interpolate:{h:f(),c:v(),l:v(),alpha:m()}},ue={mode:"cubehelix",channels:["h","s","l","alpha"],input:{rgb:function(e){e.r,e.g,e.b;var r=e.alpha,a={mode:"cubehelix"};return r!==undefind&&(a.alpha=r),a}},output:{rgb:function(e){var r=e.h,a=e.s,n=e.l,t=e.alpha,o={mode:"rgb"};r=(void 0===r?0:r+120)*w;var i=a*n*(1-n),l=Math.cos(r),h=Math.sin(r);return o.r=n+i*(y[0]*l+y[1]*h),o.g=n+i*(y[2]*l+y[3]*h),o.b=n+i*(y[4]*l+y[5]*h),void 0!==t&&(o.alpha=t),o}},interpolate:{h:f(),s:v(),l:v(),alpha:m()}};n(B),n(Q),n(U),n(X),n(Y),n(Z),n(oe),n(he),n(ue);var de=h("rgb"),se=h("lrgb"),be=h("hsl"),ge=h("hsv"),ce=h("hsi"),pe=h("hwb"),ve=h("lab"),fe=h("lch"),me=h("cubehelix"),ye=de,we=Object.freeze({hsl:be,hsv:ge,hsi:ce,hwb:pe,rgb:de,lab:ve,lch:fe,lrgb:se,cubehelix:me,formatter:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"rgb";return function(r){var a=d(r);return a.r=b(a.r),a.b=b(a.b),a.g=b(a.g),"hex"===e?"#"+(1<<24|a.r<<16|a.g<<8|a.b).toString(16).slice(1):"rgb"===e?void 0===r.alpha||1===r.alpha?"rgb("+a.r+", "+a.g+", "+a.b+")":"rgba("+a.r+", "+a.g+", "+a.b+", "+s(a.alpha)+")":void 0}},converter:h,round:u,parse:o,named:g,interpolate:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",a=arguments[2],n=function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",a=t(r).channels,n={mode:r},o=function(r){n[a[r]]=e.map(function(e){return e[a[r]]})},i=0;i<a.length;i++)o(i);return n}(e.map(h(r)),r);a=a||t(r).interpolate;var o=Object.keys(a);return function(e){e=Math.min(Math.max(0,e),1);for(var t={mode:r},i=void 0,l=0;l<o.length;l++)void 0!==(i=a[o[l]](n[o[l]],e))&&(t[o[l]]=i);return t}},interpolateNumber:v,interpolateAlpha:m,interpolateHue:f,interpolateMethodLinear:p,interpolateCubehelix:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:300,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-240,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return function(t){return k({mode:"cubehelix",h:function(e,r,a){return e+a*(r-e)}(e,r,t),l:Math.pow(t,n),s:a})}},samples:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2;if(e<2)return e<1?[]:[.5];for(var r=[],a=0;a<e;a++)r.push(a/(e-1));return r},defineMode:n,getModeDefinition:t,default:ye});return Object.assign(ye,we),ye});
!function(a,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):a.culori=e()}(this,function(){"use strict";var a={},e={},r=[],t=function(t){a[t.mode]=Object.assign(a[t.mode]||{},t.output),Object.keys(t.input||{}).forEach(function(e){a[e]||(a[e]={}),a[e][t.mode]=t.input[e]}),e[t.mode]=t,(t.parsers||[]).forEach(function(a){return r.push(a)})},n=function(a){return e[a]},o=function(a){for(var e=void 0,t=0,n=r.length;t<n&&void 0===(e=r[t++](a)););return e},i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},l=Object.assign||function(a){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(a[t]=r[t])}return a},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"rgb";return function(r){return void 0!==(r=function(a,e){return"object"!==(void 0===a?"undefined":i(a))?o(a):void 0===a.mode?l({},a,{mode:e}):a}(r,e))?r.mode===e?r:a[r.mode][e]?a[r.mode][e](r):"rgb"===e?a[r.mode].rgb(r):a.rgb[e](a[r.mode].rgb(r)):void 0}},u=function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;return function(e){return"number"==typeof e?function(a,e){return Math.round(a*(e=Math.pow(10,e)))/e}(e,a):e}},d=h("rgb"),s=u(2),b=function(a){return Math.round(255*Math.max(0,Math.min(a,1)))},g={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},c=function(a){return(a%=360)<0?a+360:a},p=function(a,e,r){return a+r*(e-a)},v=function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p;return function(e,r){var t=r*(e.length-1),n=Math.floor(t),o=e[n],i=e[n+1];return void 0!==o&&void 0!==i?a(o,i,t-n):void 0===o?i:o}},f=function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function(r,t){var n=t*(r.length-1),o=Math.floor(n),i=r[o],l=r[o+1],h=n-o;return void 0!==i&&void 0!==l?(i=c(i),l=c(l),e&&Math.abs(l-i)>180?c(a(i,l-360*Math.sign(l-i),h)):a(i,l,h)):void 0===i?l:i}},m=function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p;return function(e,r){var t=r*(e.length-1),n=Math.floor(t),o=e[n],i=e[n+1],l=t-n;if(!(void 0===o&&void 0===i||void 0===o&&0===l||void 0===i&&1===l))return a(void 0===o?1:o,void 0===i?1:i,l)}},y=function(a,e){if("number"==typeof a)return 3===e?{mode:"rgb",r:(a>>8&15|a>>4&240)/255,g:(a>>4&15|240&a)/255,b:(15&a|a<<4&240)/255}:4===e?{mode:"rgb",r:(a>>12&15|a>>8&240)/255,g:(a>>8&15|a>>4&240)/255,b:(a>>4&15|240&a)/255,alpha:(15&a|a<<4&240)/255}:6===e?{mode:"rgb",r:(a>>16&255)/255,g:(a>>8&255)/255,b:(255&a)/255}:8===e?{mode:"rgb",r:(a>>24&255)/255,g:(a>>16&255)/255,b:(a>>8&255)/255,alpha:(255&a)/255}:void 0},w=(/([+-]?\d*\.?\d+(?:[eE][+-]?\d+)?)/+"").replace(/^\/|\/$/g,""),M=w+"%",k="(?:"+w+"%|"+w+")",x="(?:"+w+"(deg|grad|rad|turn)|"+w+")",E="\\s*,\\s*",$="\\s+",q=new RegExp("^rgba?\\(\\s*"+w+E+w+E+w+"\\s*(?:,\\s*"+k+"\\s*)?\\)$"),j=new RegExp("^rgba?\\(\\s*"+M+E+M+E+M+"\\s*(?:,\\s*"+k+"\\s*)?\\)$"),R=new RegExp("^rgba?\\(\\s*"+w+$+w+$+w+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),O=new RegExp("^rgba?\\(\\s*"+M+$+M+$+M+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),I=new RegExp("^hsla?\\(\\s*"+x+E+M+E+M+"\\s*(?:,\\s*"+k+"\\s*)?\\)$"),P=new RegExp("^hsla?\\(\\s*"+x+$+M+$+M+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),z=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,S=new RegExp("^hwb\\(\\s*"+x+$+M+$+M+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),L=new RegExp("^lab\\(\\s*"+w+$+w+$+w+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),A=new RegExp("^lch\\(\\s*"+w+$+w+$+x+"\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),C=new RegExp("^gray\\(\\s*"+w+"()()\\s*(?:\\/\\s*"+k+"\\s*)?\\)$"),D={mode:"rgb",channels:["r","g","b","alpha"],parsers:[function(a){var e;return(e=a.match(z))?y(parseInt(e[1],16),e[1].length):void 0},function(a){var e=void 0,r=void 0;if(e=a.match(q)||a.match(R))r={mode:"rgb",r:e[1]/255,g:e[2]/255,b:e[3]/255};else{if(!(e=a.match(j)||a.match(O)))return;r={mode:"rgb",r:e[1]/100,g:e[2]/100,b:e[3]/100}}return void 0!==e[4]?r.alpha=e[4]/100:void 0!==e[5]&&(r.alpha=+e[5]),r},function(a){return"string"==typeof a&&y(g[a.toLowerCase()],6)||void 0},function(a){return"transparent"===a?y(0,8):void 0}],interpolate:{r:v(),g:v(),b:v(),alpha:m()}},H=function(a){return a<.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)},N=function(a){var e=a.r,r=a.g,t=a.b,n=a.alpha,o={mode:"lrgb",r:H(e),g:H(r),b:H(t)};return void 0!==n&&(o.alpha=n),o},B=function(a){return a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a},F=function(a){var e=a.r,r=a.g,t=a.b,n=a.alpha,o={mode:"rgb",r:B(e),g:B(r),b:B(t)};return void 0!==n&&(o.alpha=n),o},G={mode:"lrgb",output:{rgb:F},input:{rgb:N},channels:["r","g","b","alpha"],interpolate:{r:v(),g:v(),b:v(),alpha:m()}};var J=function(a,e){switch(e){case"deg":return+a;case"rad":return a/Math.PI*180;case"grad":return a/10*9;case"turn":return 360*a}},K={mode:"hsl",output:{rgb:function(a){var e=a.h,r=a.s,t=a.l,n=a.alpha;e=c(e);var o=t+r*(t<.5?t:1-t),i=o-2*(o-t)*Math.abs(e/60%2-1),l=void 0;switch(Math.floor(e/60)){case 0:l={r:o,g:i,b:2*t-o};break;case 1:l={r:i,g:o,b:2*t-o};break;case 2:l={r:2*t-o,g:o,b:i};break;case 3:l={r:2*t-o,g:i,b:o};break;case 4:l={r:i,g:2*t-o,b:o};break;case 5:l={r:o,g:2*t-o,b:i};break;default:l={r:2*t-o,g:2*t-o,b:2*t-o}}return l.mode="rgb",void 0!==n&&(l.alpha=n),l}},input:{rgb:function(a){var e=a.r,r=a.g,t=a.b,n=a.alpha,o=Math.max(e,r,t),i=Math.min(e,r,t),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===e?(r-t)/(o-i)+6*(r<t):o===r?(t-e)/(o-i)+2:(e-r)/(o-i)+4)),void 0!==n&&(l.alpha=n),l}},channels:["h","s","l","alpha"],parsers:[function(a){if("string"==typeof a){var e=a.match(I)||a.match(P);if(e){var r={mode:"hsl",h:void 0===e[3]?J(e[1],e[2]):+e[3],s:Math.min(Math.max(0,e[4]/100),1),l:Math.min(Math.max(0,e[5]/100),1)};return void 0!==e[6]?r.alpha=e[6]/100:void 0!==e[7]&&(r.alpha=e[7]/255),r}}}],interpolate:{h:f(),s:v(),l:v(),alpha:m()}};function Q(a){var e=a.h,r=a.s,t=a.v,n=a.alpha;e=c(e);var o=Math.abs(e/60%2-1),i=void 0;switch(Math.floor(e/60)){case 0:i={r:t,g:t*(1-r*o),b:t*(1-r)};break;case 1:i={r:t*(1-r*o),g:t,b:t*(1-r)};break;case 2:i={r:t*(1-r),g:t,b:t*(1-r*o)};break;case 3:i={r:t*(1-r),g:t*(1-r*o),b:t};break;case 4:i={r:t*(1-r*o),g:t*(1-r),b:t};break;case 5:i={r:t,g:t*(1-r),b:t*(1-r*o)};break;default:i={r:t*(1-r),g:t*(1-r),b:t*(1-r)}}return i.mode="rgb",void 0!==n&&(i.alpha=n),i}function T(a){var e=a.r,r=a.g,t=a.b,n=a.alpha,o=Math.max(e,r,t),i=Math.min(e,r,t),l={mode:"hsv",s:0===o?0:1-i/o,v:o};return o-i!=0&&(l.h=60*(o===e?(r-t)/(o-i)+6*(r<t):o===r?(t-e)/(o-i)+2:(e-r)/(o-i)+4)),void 0!==n&&(l.alpha=n),l}var U={mode:"hsv",output:{rgb:Q},input:{rgb:T},channels:["h","s","v","alpha"],interpolate:{h:f(),s:v(),v:v(),alpha:m()}};var V={mode:"hsi",output:{rgb:function(a){var e=a.h,r=a.s,t=a.i,n=a.alpha;e=c(e);var o=Math.abs(e/60%2-1),i=void 0;switch(Math.floor(e/60)){case 0:i={r:t*(1+r*(3/(2-o)-1)),g:t*(1+r*(3*(1-o)/(2-o)-1)),b:t*(1-r)};break;case 1:i={r:t*(1+r*(3*(1-o)/(2-o)-1)),g:t*(1+r*(3/(2-o)-1)),b:t*(1-r)};break;case 2:i={r:t*(1-r),g:t*(1+r*(3/(2-o)-1)),b:t*(1+r*(3*(1-o)/(2-o)-1))};break;case 3:i={r:t*(1-r),g:t*(1+r*(3*(1-o)/(2-o)-1)),b:t*(1+r*(3/(2-o)-1))};break;case 4:i={r:t*(1+r*(3*(1-o)/(2-o)-1)),g:t*(1-r),b:t*(1+r*(3/(2-o)-1))};break;case 5:i={r:t*(1+r*(3/(2-o)-1)),g:t*(1-r),b:t*(1+r*(3*(1-o)/(2-o)-1))};break;default:i={r:t*(1-r),g:t*(1-r),b:t*(1-r)}}return i.mode="rgb",void 0!==n&&(i.alpha=n),i}},input:{rgb:function(a){var e=a.r,r=a.g,t=a.b,n=a.alpha,o=Math.max(e,r,t),i=Math.min(e,r,t),l={mode:"hsi",s:e+r+t===0?0:1-3*i/(e+r+t),i:(e+r+t)/3};return o-i!=0&&(l.h=60*(o===e?(r-t)/(o-i)+6*(r<t):o===r?(t-e)/(o-i)+2:(e-r)/(o-i)+4)),void 0!==n&&(l.alpha=n),l}},channels:["h","s","i","alpha"],interpolate:{h:f(),s:v(),i:v(),alpha:m()}};var W={mode:"hwb",output:{rgb:function(a){var e=a.h,r=a.w,t=a.b,n=a.alpha;if(r+t>1){var o=r+t;r/=o,t/=o}return Q({h:e,s:1===t?1:1-r/(1-t),v:1-t,alpha:n})}},input:{rgb:function(a){var e=T(a);if(void 0!==e){var r={mode:"hwb",w:(1-e.s)*e.v,b:1-e.v};return void 0!==e.h&&(r.h=e.h),void 0!==e.alpha&&(r.alpha=e.alpha),r}}},channels:["h","w","b","alpha"],parsers:[function(a){if("string"==typeof a){var e=a.match(S);if(e){var r={mode:"hwb",h:void 0===e[3]?J(e[1],e[2]):+e[3],w:e[4]/100,b:e[5]/100};if(r.w+r.b>1){var t=r.w+r.b;r.w/=t,r.b/=t}return void 0!==e[6]?r.alpha=e[6]/100:void 0!==e[7]&&(r.alpha=e[7]/255),r}}}],interpolate:{h:f(),w:v(),b:v(),alpha:m()}},X=Math.pow(29,3)/Math.pow(3,3),Y=Math.pow(6,3)/Math.pow(29,3),Z=function(a){return Math.pow(a,3)>Y?Math.pow(a,3):(116*a-16)/X},_=function(a){var e,r,t,n,o,i=function(a){var e=a.x,r=a.y,t=a.z;return F({r:3.1338561*e-1.6168667*r-.4906146*t,g:-.9787684*e+1.9161415*r+.033454*t,b:.0719453*e-.2289914*r+1.4052427*t})}((r=(e=a).l,t=e.a,o=(n=(r+16)/116)-e.b/200,{x:.96422*Z(t/500+n),y:1*Z(n),z:.82521*Z(o)}));return i.mode="rgb",void 0!==a.alpha&&(i.alpha=a.alpha),i},aa=function(a){return a>Y?Math.cbrt(a):(X*a+16)/116},ea=function(a){var e,r,t,n,o,i,l=(e=function(a){var e=N(a),r=e.r,t=e.g,n=e.b;return{x:.4360747*r+.3850649*t+.1430804*n,y:.2225045*r+.7168786*t+.0606169*n,z:.0139322*r+.0971045*t+.7141733*n}}(a),r=e.x,t=e.y,n=e.z,o=aa(r/.96422),{mode:"lab",l:116*(i=aa(t/1))-16,a:500*(o-i),b:200*(i-aa(n/.82521))});return a.r===a.b===a.g&&(l.a=l.b=0),void 0!==a.alpha&&(l.alpha=a.alpha),l},ra={mode:"lab",output:{rgb:_},input:{rgb:ea},channels:["l","a","b","alpha"],parsers:[function(a){var e=void 0,r=void 0;if(e=a.match(L))r={mode:"lab",l:+e[1],a:+e[2],b:+e[3]};else{if(!(e=a.match(C)))return;r={mode:"lab",l:+e[1],a:0,b:0}}return void 0!==e[4]?r.alpha=e[4]/100:void 0!==e[5]&&(r.alpha=+e[5]),r}],interpolate:{l:v(),a:v(),b:v(),alpha:m()}},ta=function(a){var e=a.l,r=a.a,t=a.b,n=a.alpha,o=Math.sqrt(r*r+t*t),i={mode:"lch",l:e,c:o};return o&&(i.h=c(180*Math.atan2(t,r)/Math.PI)),void 0!==n&&(i.alpha=n),i},na=function(a){var e=a.l,r=a.c,t=a.h,n=a.alpha,o={mode:"lab",l:e,a:0===r?0:r*Math.cos(t/180*Math.PI),b:0===r?0:r*Math.sin(t/180*Math.PI)};return void 0!==n&&(o.alpha=n),o},oa={mode:"lch",output:{lab:na,rgb:function(a){return _(na(a))}},input:{rgb:function(a){return ta(ea(a))},lch:ta},channels:["l","c","h","alpha"],parsers:[function(a){var e=a.match(A);if(e){var r={mode:"lch",l:+e[1],c:Math.max(0,+e[2]),h:void 0===e[5]?J(e[3],e[4]):+e[5]};return void 0!==e[6]?r.alpha=e[6]/100:void 0!==e[7]&&(r.alpha=+e[7]),r}}],interpolate:{h:f(),c:v(),l:v(),alpha:m()}},ia=[-.14861,1.78277,-.29227,-.90649,1.97294,0],la=Math.PI/180,ha=180*Math.PI,ua=ia[1]*ia[2]-ia[3]*ia[0],da=ia[4]*ia[3],sa=ia[4]*ia[1],ba={mode:"cubehelix",channels:["h","s","l","alpha"],input:{rgb:function(a){var e=a.r,r=a.g,t=a.b,n=a.alpha,o=(ua*t+da*e-sa*r)/(ua+da-sa),i=t-o,l=(ia[4]*(r-o)-ia[2]*i)/ia[3],h={mode:"cubehelix",l:o,s:Math.sqrt(l*l+i*i)/(ia[4]*o*(1-o))};return 0!==h.s&&(h.h=c(Math.atan2(l,i)*ha-120)),void 0!==n&&(h.alpha=n),h}},output:{rgb:function(a){var e=a.h,r=a.s,t=a.l,n=a.alpha,o={mode:"rgb"};e=(void 0===e?0:e+120)*la;var i=r*t*(1-t),l=Math.cos(e),h=Math.sin(e);return o.r=t+i*(ia[0]*l+ia[1]*h),o.g=t+i*(ia[2]*l+ia[3]*h),o.b=t+i*(ia[4]*l+ia[5]*h),void 0!==n&&(o.alpha=n),o}},interpolate:{h:f(p,!1),s:v(),l:v(),alpha:m()}};t(D),t(G),t(K),t(U),t(V),t(W),t(ra),t(oa),t(ba);var ga=h("rgb"),ca=h("lrgb"),pa=h("hsl"),va=h("hsv"),fa=h("hsi"),ma=h("hwb"),ya=h("lab"),wa=h("lch"),Ma=h("cubehelix"),ka=ga,xa=Object.freeze({hsl:pa,hsv:va,hsi:fa,hwb:ma,rgb:ga,lab:ya,lch:wa,lrgb:ca,cubehelix:Ma,formatter:function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"rgb";return function(e){var r=d(e);return r.r=b(r.r),r.b=b(r.b),r.g=b(r.g),"hex"===a?"#"+(1<<24|r.r<<16|r.g<<8|r.b).toString(16).slice(1):"rgb"===a?void 0===e.alpha||1===e.alpha?"rgb("+r.r+", "+r.g+", "+r.b+")":"rgba("+r.r+", "+r.g+", "+r.b+", "+s(r.alpha)+")":void 0}},converter:h,round:u,parse:o,named:g,interpolate:function(a){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",r=arguments[2],t=function(a){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",r=n(e).channels,t={mode:e},o=function(e){t[r[e]]=a.map(function(a){return a[r[e]]})},i=0;i<r.length;i++)o(i);return t}(a.map(h(e)),e);r=r||n(e).interpolate;var o=Object.keys(r);return function(a){a=Math.min(Math.max(0,a),1);for(var n={mode:e},i=void 0,l=0;l<o.length;l++)void 0!==(i=r[o[l]](t[o[l]],a))&&(n[o[l]]=i);return n}},interpolateNumber:v,interpolateAlpha:m,interpolateHue:f,interpolateMethodLinear:p,samples:function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2;if(a<2)return a<1?[]:[.5];for(var e=[],r=0;r<a;r++)e.push(r/(a-1));return e},defineMode:t,getModeDefinition:n,default:ka});return Object.assign(ka,xa),ka});

@@ -371,26 +371,2 @@ var converters = {};

var M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];
var degToRad = Math.PI / 180;
var linear = function linear(a, b, t) {
return a + t * (b - a);
};
var rgb$1 = converter('rgb');
var interpolateCubehelix = (function () {
var starthue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 300;
var endhue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -240;
var saturation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
var gamma = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
return function (t) {
return rgb$1({
mode: 'cubehelix',
h: linear(starthue, endhue, t),
l: Math.pow(t, gamma),
s: saturation
});
};
});
var samples = (function () {

@@ -1257,2 +1233,19 @@ var count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;

var M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];
var degToRad = Math.PI / 180;
var radToDeg = 180 * Math.PI;
/*
This RGB to Cubehelix conversion is based on
Mike Bostock's work in d3-color.
Reference:
https://github.com/d3/d3-color/blob/master/src/cubehelix.js
*/
var x = M[1] * M[2] - M[3] * M[0];
var y = M[4] * M[3];
var z = M[4] * M[1];
var convertRgbToCubehelix = (function (_ref) {

@@ -1264,4 +1257,16 @@ var r = _ref.r,

var res = { mode: 'cubehelix' };
if (alpha !== undefind) res.alpha = alpha;
var l = (x * b + y * r - z * g) / (x + y - z);
var bl = b - l;
var k = (M[4] * (g - l) - M[2] * bl) / M[3];
var res = {
mode: 'cubehelix',
l: l,
s: Math.sqrt(k * k + bl * bl) / (M[4] * l * (1 - l))
};
if (res.s !== 0) res.h = normalizeHue(Math.atan2(k, bl) * radToDeg - 120);
if (alpha !== undefined) res.alpha = alpha;
return res;

@@ -1314,3 +1319,3 @@ });

interpolate: {
'h': interpolateHue(),
'h': interpolateHue(interpolateMethodLinear, false),
's': interpolateNumber(),

@@ -1332,3 +1337,3 @@ 'l': interpolateNumber(),

var rgb$2 = converter('rgb');
var rgb$1 = converter('rgb');
var lrgb = converter('lrgb');

@@ -1343,5 +1348,5 @@ var hsl = converter('hsl');

var culori = rgb$2;
var culori = rgb$1;
export default culori;
export { hsl, hsv, hsi, hwb$1 as hwb, rgb$2 as rgb, lab$1 as lab, lch$1 as lch, lrgb, cubehelix, formatter, converter, round, parse, named, interpolate, interpolateNumber, interpolateAlpha, interpolateHue, interpolateMethodLinear, interpolateCubehelix, samples, defineMode, getModeDefinition };
export { hsl, hsv, hsi, hwb$1 as hwb, rgb$1 as rgb, lab$1 as lab, lch$1 as lch, lrgb, cubehelix, formatter, converter, round, parse, named, interpolate, interpolateNumber, interpolateAlpha, interpolateHue, interpolateMethodLinear, samples, defineMode, getModeDefinition };
{
"name": "culori",
"version": "0.2.71",
"version": "0.2.72",
"main": "build/culori.js",

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

@@ -7,2 +7,3 @@ export const M = [

export const degToRad = Math.PI / 180;
export const degToRad = Math.PI / 180;
export const radToDeg = 180 * Math.PI;

@@ -0,5 +1,32 @@

/*
This RGB to Cubehelix conversion is based on
Mike Bostock's work in d3-color.
Reference:
https://github.com/d3/d3-color/blob/master/src/cubehelix.js
*/
import { radToDeg, M } from './constants';
import normalizeHue from '../util/normalizeHue';
let x = M[1] * M[2] - M[3] * M[0];
let y = M[4] * M[3];
let z = M[4] * M[1];
export default ({ r, g, b, alpha }) => {
let res = { mode: 'cubehelix' };
if (alpha !== undefind) res.alpha = alpha;
let l = (x * b + y * r - z * g) / (x + y - z);
let bl = b - l;
let k = (M[4] * (g - l) - M[2] * bl) / M[3];
let res = {
mode: 'cubehelix',
l: l,
s: Math.sqrt(k * k + bl * bl) / (M[4] * l * (1 - l))
};
if (res.s !== 0) res.h = normalizeHue(Math.atan2(k, bl) * radToDeg - 120);
if (alpha !== undefined) res.alpha = alpha;
return res;
}

@@ -12,3 +12,3 @@ /*

import { interpolateNumber, interpolateAlpha, interpolateHue } from '../interpolate';
import { interpolateNumber, interpolateAlpha, interpolateHue, interpolateMethodLinear } from '../interpolate';
import convertRgbToCubehelix from './convertRgbToCubehelix';

@@ -27,3 +27,3 @@ import convertCubehelixToRgb from './convertCubehelixToRgb';

interpolate: {
'h': interpolateHue(),
'h': interpolateHue(interpolateMethodLinear, false),
's': interpolateNumber(),

@@ -30,0 +30,0 @@ 'l': interpolateNumber(),

@@ -11,3 +11,2 @@ import formatter from './formatter';

} from './interpolate';
import interpolateCubehelix from './interpolateCubehelix';
import samples from './samples';

@@ -72,3 +71,2 @@ import zip from './zip';

interpolateMethodLinear,
interpolateCubehelix,
samples,

@@ -75,0 +73,0 @@ defineMode,

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