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.68 to 0.2.69

src/cubehelix/definition.js

80

build/culori.js

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

var M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];
var degToRad = Math.PI / 180;
var interpolateCubehelix = (function () {
var startcolor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5;
var turns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1.5;
var chroma = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var gamma = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
return function (t) {
var res = {
mode: 'rgb'
};
var l = Math.pow(t, gamma);
var theta = 360 * (startcolor / 3 + turns * t) * degToRad;
var amp = chroma / 2 * t * (1 - t);
var cosh = Math.cos(theta);
var sinh = Math.sin(theta);
res.r = l + amp * (M[0] * cosh + M[1] * sinh);
res.g = l + amp * (M[2] * cosh + M[3] * sinh);
res.b = l + amp * (M[4] * cosh + M[5] * sinh);
return res;
};
});
var samples = (function () {

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

// function displayable(c) {
// let color = convertLchToRgb(c);
// return color.r >= 0 && color.r <= 1 &&
// color.g >= 0 && color.g <=1 &&
// color.b >= 0 && color.b <=1;
// }
/*
Dave Green's Cubehelix
----------------------
Green, D. A., 2011, "A colour scheme for the display of astronomical intensity images",
Bulletin of the Astronomical Society of India, 39, 289. (2011BASI...39..289G at ADS.)
// function search(start, end, testFn) {
// let middle = (end - start)/2;
// if (testFn(middle)) {
// // middle is displayable
// return search(middle, end, testFn);
// } else {
// return search(start, middle, testFn);
// }
// }
https://www.mrao.cam.ac.uk/%7Edag/CUBEHELIX/
https://arxiv.org/pdf/1108.5083.pdf
*/
// function clamp(color) {
// if (!displayable(color)) {
// let _color = Object.assign({}, color);
// let chroma = search(start, _color.c, chroma => (_color.c = chroma, displayable(_color)));
// } else {
// return color;
// }
// }
var cubehelixDef = {
mode: 'cubehelix',
channels: ['l', // lightness
's', // start color
'r', // rotations
'c' // chroma (defined as 'hue' in Green's paper)
],
input: {
rgb: function rgb() {}
},
output: {
rgb: function rgb() {}
}
};

@@ -1275,2 +1305,3 @@ defineMode(rgbDef);

defineMode(lchDef);
defineMode(cubehelixDef);

@@ -1285,2 +1316,3 @@ var rgb$1 = converter('rgb');

var lch$1 = converter('lch');
var cubehelix = converter('cubehelix');

@@ -1298,2 +1330,3 @@ var culori = rgb$1;

lrgb: lrgb,
cubehelix: cubehelix,
formatter: formatter,

@@ -1309,2 +1342,3 @@ converter: converter,

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

@@ -1311,0 +1345,0 @@ defineMode: defineMode,

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

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

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

var M = [-0.14861, 1.78277, -0.29227, -0.90649, 1.97294, 0];
var degToRad = Math.PI / 180;
var interpolateCubehelix = (function () {
var startcolor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5;
var turns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1.5;
var chroma = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var gamma = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
return function (t) {
var res = {
mode: 'rgb'
};
var l = Math.pow(t, gamma);
var theta = 360 * (startcolor / 3 + turns * t) * degToRad;
var amp = chroma / 2 * t * (1 - t);
var cosh = Math.cos(theta);
var sinh = Math.sin(theta);
res.r = l + amp * (M[0] * cosh + M[1] * sinh);
res.g = l + amp * (M[2] * cosh + M[3] * sinh);
res.b = l + amp * (M[4] * cosh + M[5] * sinh);
return res;
};
});
var samples = (function () {

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

// function displayable(c) {
// let color = convertLchToRgb(c);
// return color.r >= 0 && color.r <= 1 &&
// color.g >= 0 && color.g <=1 &&
// color.b >= 0 && color.b <=1;
// }
/*
Dave Green's Cubehelix
----------------------
Green, D. A., 2011, "A colour scheme for the display of astronomical intensity images",
Bulletin of the Astronomical Society of India, 39, 289. (2011BASI...39..289G at ADS.)
// function search(start, end, testFn) {
// let middle = (end - start)/2;
// if (testFn(middle)) {
// // middle is displayable
// return search(middle, end, testFn);
// } else {
// return search(start, middle, testFn);
// }
// }
https://www.mrao.cam.ac.uk/%7Edag/CUBEHELIX/
https://arxiv.org/pdf/1108.5083.pdf
*/
// function clamp(color) {
// if (!displayable(color)) {
// let _color = Object.assign({}, color);
// let chroma = search(start, _color.c, chroma => (_color.c = chroma, displayable(_color)));
// } else {
// return color;
// }
// }
var cubehelixDef = {
mode: 'cubehelix',
channels: ['l', // lightness
's', // start color
'r', // rotations
'c' // chroma (defined as 'hue' in Green's paper)
],
input: {
rgb: function rgb() {}
},
output: {
rgb: function rgb() {}
}
};

@@ -1269,2 +1299,3 @@ defineMode(rgbDef);

defineMode(lchDef);
defineMode(cubehelixDef);

@@ -1279,2 +1310,3 @@ var rgb$1 = converter('rgb');

var lch$1 = converter('lch');
var cubehelix = converter('cubehelix');

@@ -1284,2 +1316,2 @@ var culori = rgb$1;

export default culori;
export { hsl, hsv, hsi, hwb$1 as hwb, rgb$1 as rgb, lab$1 as lab, lch$1 as lch, lrgb, formatter, converter, round, parse, named, interpolate, interpolateNumber, interpolateAlpha, interpolateHue, interpolateMethodLinear, 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, interpolateCubehelix, samples, defineMode, getModeDefinition };
{
"name": "culori",
"version": "0.2.68",
"version": "0.2.69",
"main": "build/culori.js",

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

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

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

@@ -27,2 +28,3 @@ import zip from './zip';

import lchDef from './lch/definition';
import cubehelixDef from './cubehelix/definition';

@@ -37,2 +39,3 @@ defineMode(rgbDef);

defineMode(lchDef);
defineMode(cubehelixDef);

@@ -47,2 +50,3 @@ let rgb = converter('rgb');

let lch = converter('lch');
let cubehelix = converter('cubehelix');

@@ -60,2 +64,3 @@ const culori = rgb;

lrgb,
cubehelix,
formatter,

@@ -71,4 +76,4 @@ converter,

interpolateMethodLinear,
interpolateCubehelix,
samples,
defineMode,

@@ -75,0 +80,0 @@ getModeDefinition

@@ -26,30 +26,2 @@ import convertLabToLch from './convertLabToLch';

}
};
// function displayable(c) {
// let color = convertLchToRgb(c);
// return color.r >= 0 && color.r <= 1 &&
// color.g >= 0 && color.g <=1 &&
// color.b >= 0 && color.b <=1;
// }
// function search(start, end, testFn) {
// let middle = (end - start)/2;
// if (testFn(middle)) {
// // middle is displayable
// return search(middle, end, testFn);
// } else {
// return search(start, middle, testFn);
// }
// }
// function clamp(color) {
// if (!displayable(color)) {
// let _color = Object.assign({}, color);
// let chroma = search(start, _color.c, chroma => (_color.c = chroma, displayable(_color)));
// } else {
// return color;
// }
// }
};
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