Comparing version 0.2.74 to 0.2.75
@@ -1251,6 +1251,12 @@ (function (global, factory) { | ||
var x = M[1] * M[2] - M[3] * M[0]; | ||
var y = M[4] * M[3]; | ||
var z = M[4] * M[1]; | ||
var A = M[0], | ||
B = M[1], | ||
C = M[2], | ||
D = M[3], | ||
E = M[4]; | ||
var ED = E * D, | ||
EB = E * B, | ||
BC_DA = B * C - D * A; | ||
var convertRgbToCubehelix = (function (_ref) { | ||
@@ -1263,5 +1269,5 @@ var r = _ref.r, | ||
var l = (x * b + y * r - z * g) / (x + y - z); | ||
var l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB); | ||
var bl = b - l; | ||
var k = (M[4] * (g - l) - M[2] * bl) / M[3]; | ||
var k = (E * (g - l) - C * bl) / D; | ||
@@ -1271,6 +1277,6 @@ var res = { | ||
l: l, | ||
s: l === 0 || l === 1 ? undefined : Math.sqrt(k * k + bl * bl) / (M[4] * l * (1 - l)) | ||
s: l === 0 || l === 1 ? undefined : Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)) | ||
}; | ||
if (res.s) res.h = normalizeHue(Math.atan2(k, bl) * radToDeg - 120); | ||
if (res.s) res.h = Math.atan2(k, bl) * radToDeg - 120; | ||
if (alpha !== undefined) res.alpha = alpha; | ||
@@ -1325,3 +1331,3 @@ | ||
interpolate: { | ||
'h': interpolateHue(interpolateMethodLinear, false), | ||
'h': interpolateHue(), | ||
's': interpolateNumber(), | ||
@@ -1328,0 +1334,0 @@ 'l': interpolateNumber(), |
@@ -1,1 +0,1 @@ | ||
!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:0===o||1===o?void 0:Math.sqrt(l*l+i*i)/(ia[4]*o*(1-o))};return 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}); | ||
!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],da=ia[2],sa=ia[3],ba=ia[4],ga=ba*sa,ca=ba*ua,pa=ua*da-sa*ia[0],va={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=(pa*t+ga*e-ca*r)/(pa+ga-ca),i=t-o,l=(ba*(r-o)-da*i)/sa,h={mode:"cubehelix",l:o,s:0===o||1===o?void 0:Math.sqrt(l*l+i*i)/(ba*o*(1-o))};return h.s&&(h.h=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(),s:v(),l:v(),alpha:m()}};t(D),t(G),t(K),t(U),t(V),t(W),t(ra),t(oa),t(va);var fa=h("rgb"),ma=h("lrgb"),ya=h("hsl"),wa=h("hsv"),Ma=h("hsi"),ka=h("hwb"),xa=h("lab"),Ea=h("lch"),$a=h("cubehelix"),qa=fa,ja=Object.freeze({hsl:ya,hsv:wa,hsi:Ma,hwb:ka,rgb:fa,lab:xa,lch:Ea,lrgb:ma,cubehelix:$a,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:qa});return Object.assign(qa,ja),qa}); |
@@ -1245,6 +1245,12 @@ var converters = {}; | ||
var x = M[1] * M[2] - M[3] * M[0]; | ||
var y = M[4] * M[3]; | ||
var z = M[4] * M[1]; | ||
var A = M[0], | ||
B = M[1], | ||
C = M[2], | ||
D = M[3], | ||
E = M[4]; | ||
var ED = E * D, | ||
EB = E * B, | ||
BC_DA = B * C - D * A; | ||
var convertRgbToCubehelix = (function (_ref) { | ||
@@ -1257,5 +1263,5 @@ var r = _ref.r, | ||
var l = (x * b + y * r - z * g) / (x + y - z); | ||
var l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB); | ||
var bl = b - l; | ||
var k = (M[4] * (g - l) - M[2] * bl) / M[3]; | ||
var k = (E * (g - l) - C * bl) / D; | ||
@@ -1265,6 +1271,6 @@ var res = { | ||
l: l, | ||
s: l === 0 || l === 1 ? undefined : Math.sqrt(k * k + bl * bl) / (M[4] * l * (1 - l)) | ||
s: l === 0 || l === 1 ? undefined : Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)) | ||
}; | ||
if (res.s) res.h = normalizeHue(Math.atan2(k, bl) * radToDeg - 120); | ||
if (res.s) res.h = Math.atan2(k, bl) * radToDeg - 120; | ||
if (alpha !== undefined) res.alpha = alpha; | ||
@@ -1319,3 +1325,3 @@ | ||
interpolate: { | ||
'h': interpolateHue(interpolateMethodLinear, false), | ||
'h': interpolateHue(), | ||
's': interpolateNumber(), | ||
@@ -1322,0 +1328,0 @@ 'l': interpolateNumber(), |
{ | ||
"name": "culori", | ||
"version": "0.2.74", | ||
"version": "0.2.75", | ||
"main": "build/culori.js", | ||
@@ -5,0 +5,0 @@ "module": "build/index.js", |
@@ -12,11 +12,17 @@ /* | ||
let x = M[1] * M[2] - M[3] * M[0]; | ||
let y = M[4] * M[3]; | ||
let z = M[4] * M[1]; | ||
let A = M[0], | ||
B = M[1], | ||
C = M[2], | ||
D = M[3], | ||
E = M[4]; | ||
let ED = E * D, | ||
EB = E * B, | ||
BC_DA = B * C - D * A; | ||
export default ({ r, g, b, alpha }) => { | ||
let l = (x * b + y * r - z * g) / (x + y - z); | ||
let l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB); | ||
let bl = b - l; | ||
let k = (M[4] * (g - l) - M[2] * bl) / M[3]; | ||
let k = (E * (g - l) - C * bl) / D; | ||
@@ -26,6 +32,6 @@ let res = { | ||
l: l, | ||
s: (l === 0 || l === 1) ? undefined : Math.sqrt(k * k + bl * bl) / (M[4] * l * (1 - l)) | ||
s: (l === 0 || l === 1) ? undefined : Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)) | ||
}; | ||
if (res.s) res.h = normalizeHue(Math.atan2(k, bl) * radToDeg - 120); | ||
if (res.s) res.h = Math.atan2(k, bl) * radToDeg - 120; | ||
if (alpha !== undefined) res.alpha = alpha; | ||
@@ -32,0 +38,0 @@ |
@@ -26,3 +26,3 @@ /* | ||
interpolate: { | ||
'h': interpolateHue(interpolateMethodLinear, false), | ||
'h': interpolateHue(), | ||
's': interpolateNumber(), | ||
@@ -29,0 +29,0 @@ 'l': interpolateNumber(), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125415
3803