Comparing version 0.2.55 to 0.2.56
@@ -371,3 +371,3 @@ (function (global, factory) { | ||
var gamma = beta > 0 ? 1 - beta : 1 / (1 + beta); | ||
// let gamma = beta > 0 ? 1 - beta : 1 / (1 + beta); | ||
var conv = converter(mode); | ||
@@ -383,5 +383,5 @@ | ||
case 'lrgb': | ||
res.r = Math.pow(res.r, 2.2 / gamma); | ||
res.g = Math.pow(res.g, 2.2 / gamma); | ||
res.b = Math.pow(res.b, 2.2 / gamma); | ||
res.r = Math.pow(res.r, 2.2 / beta); | ||
res.g = Math.pow(res.g, 2.2 / beta); | ||
res.b = Math.pow(res.b, 2.2 / beta); | ||
break; | ||
@@ -388,0 +388,0 @@ case 'hsl': |
@@ -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){var n=t.mode,o=t.input,i=t.output,l=t.keys,h=t.parsers;r[n]=Object.assign(r[n]||{},i),Object.keys(o||{}).forEach(function(e){r[e]||(r[e]={}),r[e][n]=o[e]}),e[n]=l,(h||[]).forEach(function(r){return a.push(r)})},n=function(r){for(var e=void 0,t=0,n=a.length;t<n&&void 0===(e=a[t++](r)););return e},o="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},i=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},l=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":o(r))?n(r):void 0===r.mode?i({},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}},h=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}},u=function(r,e){return e},s=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;return function(a){var t={mode:a.mode},n=void 0;return e[a.mode].forEach(function(e){void 0!==(n=r(a[e],e))&&(t[e]=n)}),t}},d=s(function(r,e){return"alpha"===e?r:Math.round(255*Math.max(0,Math.min(r,1)))}),b=l("rgb"),g=h(2),c={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},p=function(r){return(r%=360)<0?r+360:r},v=function(r,e,a){return r+a*(e-r)},f=function(r,e,a){return void 0!==r&&void 0!==e?v(r,e,a):void 0===r?e:r},m=function(r,e,a){return void 0!==r&&void 0!==e?(r=p(r),e=p(e),Math.abs(e-r)>180?p(v(r,e-360*Math.sign(e-r),a)):v(r,e,a)):void 0===r?e:r},y=function(r,e,a){if(!(void 0===r&&void 0===e||void 0===r&&0===a||void 0===e&&1===a))return v(void 0===r?1:r,void 0===e?1:e,a)},k=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,""),M=w+"%",x="(?:"+w+"%|"+w+")",E="(?:"+w+"(deg|grad|rad|turn)|"+w+")",$="\\s*,\\s*",j="\\s+",q=new RegExp("^rgba?\\(\\s*"+w+$+w+$+w+"\\s*(?:,\\s*"+x+"\\s*)?\\)$"),R=new RegExp("^rgba?\\(\\s*"+M+$+M+$+M+"\\s*(?:,\\s*"+x+"\\s*)?\\)$"),O=new RegExp("^rgba?\\(\\s*"+w+j+w+j+w+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),z=new RegExp("^rgba?\\(\\s*"+M+j+M+j+M+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),S=new RegExp("^hsla?\\(\\s*"+E+$+M+$+M+"\\s*(?:,\\s*"+x+"\\s*)?\\)$"),I=new RegExp("^hsla?\\(\\s*"+E+j+M+j+M+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),P=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,C=new RegExp("^hwb\\(\\s*"+E+j+M+j+M+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),L=new RegExp("^lab\\(\\s*"+w+j+w+j+w+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),A=new RegExp("^lch\\(\\s*"+w+j+w+j+E+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),B=new RegExp("^gray\\(\\s*"+w+"()()\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),D={mode:"rgb",keys:["r","g","b","alpha"],parsers:[function(r){var e;return(e=r.match(P))?k(parseInt(e[1],16),e[1].length):void 0},function(r){var e=void 0,a=void 0;if(e=r.match(q)||r.match(O))a={mode:"rgb",r:e[1]/255,g:e[2]/255,b:e[3]/255};else{if(!(e=r.match(R)||r.match(z)))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&&k(c[r.toLowerCase()],6)||void 0},function(r){return"transparent"===r?k(0,8):void 0}]},F=function(r){return r<.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)},G=function(r){var e=r.r,a=r.g,t=r.b,n=r.alpha,o={mode:"lrgb",r:F(e),g:F(a),b:F(t)};return void 0!==n&&(o.alpha=n),o},H=function(r){return r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r},J=function(r){var e=r.r,a=r.g,t=r.b,n=r.alpha,o={mode:"rgb",r:H(e),g:H(a),b:H(t)};return void 0!==n&&(o.alpha=n),o},K={mode:"lrgb",output:{rgb:J},input:{rgb:G},keys:["r","g","b","alpha"]};var N=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}},Q={mode:"hsl",output:{rgb:function(r){var e=r.h,a=r.s,t=r.l,n=r.alpha;e=p(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}},keys:["h","s","l","alpha"],parsers:[function(r){if("string"==typeof r){var e=r.match(S)||r.match(I);if(e){var a={mode:"hsl",h:void 0===e[3]?N(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}}}]};function T(r){var e=r.h,a=r.s,t=r.v,n=r.alpha;e=p(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 U(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 V={mode:"hsv",output:{rgb:T},input:{rgb:U},keys:["h","s","v","alpha"]};var W={mode:"hsi",output:{rgb:function(r){var e=r.h,a=r.s,t=r.i,n=r.alpha;e=p(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}},keys:["h","s","i","alpha"]};var X={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 T({h:e,s:1===t?1:1-a/(1-t),v:1-t,alpha:n})}},input:{rgb:function(r){var e=U(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}}},keys:["h","w","b","alpha"],parsers:[function(r){if("string"==typeof r){var e=r.match(C);if(e){var a={mode:"hwb",h:void 0===e[3]?N(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}}}]},Y=Math.pow(29,3)/Math.pow(3,3),Z=Math.pow(6,3)/Math.pow(29,3),_=function(r){return Math.pow(r,3)>Z?Math.pow(r,3):(116*r-16)/Y},rr=function(r){var e,a,t,n,o,i=function(r){var e=r.x,a=r.y,t=r.z;return J({r:3.2404542*e-1.5371385*a-.4985314*t,g:-.969266*e+1.8760108*a+.041556*t,b:.0556434*e-.2040259*a+1.0572252*t})}((a=(e=r).l,t=e.a,o=(n=(a+16)/116)-e.b/200,{x:.95047*_(t/500+n),y:1*_(n),z:1.08883*_(o)}));return i.mode="rgb",void 0!==r.alpha&&(i.alpha=r.alpha),i},er=function(r){return r>Z?Math.cbrt(r):(Y*r+16)/116},ar=function(r){var e,a,t,n,o,i,l=(e=function(r){var e=G(r),a=e.r,t=e.g,n=e.b;return{x:.4124564*a+.3575761*t+.1804375*n,y:.2126729*a+.7151522*t+.072175*n,z:.0193339*a+.119192*t+.9503041*n}}(r),a=e.x,t=e.y,n=e.z,o=er(a/.95047),{l:116*(i=er(t/1))-16,a:500*(o-i),b:200*(i-er(n/1.08883))});return l.mode="lab",void 0!==r.alpha&&(l.alpha=r.alpha),l},tr={mode:"lab",output:{rgb:rr},input:{rgb:ar},keys:["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(B)))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}]},nr=h(4),or=function(r){var e=r.l,a=r.a,t=r.b,n=r.alpha,o=nr(Math.sqrt(a*a+t*t)),i={mode:"lch",l:e,c:o};return o&&(i.h=p(180*Math.atan2(t,a)/Math.PI)),void 0!==n&&(i.alpha=n),i},ir=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},lr={mode:"lch",output:{lab:ir,rgb:function(r){return rr(ir(r))}},input:{rgb:function(r){return or(ar(r))},lch:or},keys:["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]?N(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}}]};t(D),t(K),t(Q),t(V),t(W),t(X),t(tr),t(lr);var hr=l("rgb"),ur=l("lrgb"),sr=l("hsl"),dr=l("hsv"),br=l("hsi"),gr=l("hwb"),cr=l("lab"),pr=l("lch"),vr=hr,fr=Object.freeze({hsl:sr,hsv:dr,hsi:br,hwb:gr,rgb:hr,lab:cr,lch:pr,lrgb:ur,css:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"rgb";return function(e){var a=d(b(e));return"hex"===r?"#"+(1<<24|a.r<<16|a.g<<8|a.b).toString(16).slice(1):"rgb"===r?void 0===a.alpha||255===a.alpha?"rgb("+a.r+", "+a.g+", "+a.b+")":"rgba("+a.r+", "+a.g+", "+a.b+", "+g(a.alpha)+")":void 0}},converter:l,brighten:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",a=r>0?1-r:1/(1+r),t=l(e);return function(r){var n=l(r.mode),o=Object.assign({},t(r));switch(e){case"rgb":case"lrgb":o.r=Math.pow(o.r,2.2/a),o.g=Math.pow(o.g,2.2/a),o.b=Math.pow(o.b,2.2/a);break;case"hsl":case"lab":case"lch":o.l*=exp;break;case"hsv":o.v*=exp;break;case"hsi":o.i*=exp}return n(o)}},round:h,parse:n,named:c,transform:s,interpolate:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb";if(!(r.length<2)){var a=r.map(l(e));return function(r){var t=(r=Math.min(Math.max(0,r),1))*(a.length-1),n=Math.floor(t),o=a[n],i=1===r?a[n]:a[n+1],l=t-n;return s(function(r,e){return("h"===e?m:"alpha"===e?y:f)(o[e],i[e],l)})({mode:e})}}},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},default:vr});return Object.assign(vr,fr),vr}); | ||
!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){var n=t.mode,o=t.input,i=t.output,l=t.keys,h=t.parsers;r[n]=Object.assign(r[n]||{},i),Object.keys(o||{}).forEach(function(e){r[e]||(r[e]={}),r[e][n]=o[e]}),e[n]=l,(h||[]).forEach(function(r){return a.push(r)})},n=function(r){for(var e=void 0,t=0,n=a.length;t<n&&void 0===(e=a[t++](r)););return e},o="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},i=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},l=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":o(r))?n(r):void 0===r.mode?i({},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}},h=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}},u=function(r,e){return e},s=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;return function(a){var t={mode:a.mode},n=void 0;return e[a.mode].forEach(function(e){void 0!==(n=r(a[e],e))&&(t[e]=n)}),t}},d=s(function(r,e){return"alpha"===e?r:Math.round(255*Math.max(0,Math.min(r,1)))}),b=l("rgb"),g=h(2),c={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},p=function(r){return(r%=360)<0?r+360:r},v=function(r,e,a){return r+a*(e-r)},f=function(r,e,a){return void 0!==r&&void 0!==e?v(r,e,a):void 0===r?e:r},m=function(r,e,a){return void 0!==r&&void 0!==e?(r=p(r),e=p(e),Math.abs(e-r)>180?p(v(r,e-360*Math.sign(e-r),a)):v(r,e,a)):void 0===r?e:r},y=function(r,e,a){if(!(void 0===r&&void 0===e||void 0===r&&0===a||void 0===e&&1===a))return v(void 0===r?1:r,void 0===e?1:e,a)},k=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,""),M=w+"%",x="(?:"+w+"%|"+w+")",E="(?:"+w+"(deg|grad|rad|turn)|"+w+")",$="\\s*,\\s*",j="\\s+",q=new RegExp("^rgba?\\(\\s*"+w+$+w+$+w+"\\s*(?:,\\s*"+x+"\\s*)?\\)$"),R=new RegExp("^rgba?\\(\\s*"+M+$+M+$+M+"\\s*(?:,\\s*"+x+"\\s*)?\\)$"),O=new RegExp("^rgba?\\(\\s*"+w+j+w+j+w+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),z=new RegExp("^rgba?\\(\\s*"+M+j+M+j+M+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),S=new RegExp("^hsla?\\(\\s*"+E+$+M+$+M+"\\s*(?:,\\s*"+x+"\\s*)?\\)$"),I=new RegExp("^hsla?\\(\\s*"+E+j+M+j+M+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),P=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,C=new RegExp("^hwb\\(\\s*"+E+j+M+j+M+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),L=new RegExp("^lab\\(\\s*"+w+j+w+j+w+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),A=new RegExp("^lch\\(\\s*"+w+j+w+j+E+"\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),B=new RegExp("^gray\\(\\s*"+w+"()()\\s*(?:\\/\\s*"+x+"\\s*)?\\)$"),D={mode:"rgb",keys:["r","g","b","alpha"],parsers:[function(r){var e;return(e=r.match(P))?k(parseInt(e[1],16),e[1].length):void 0},function(r){var e=void 0,a=void 0;if(e=r.match(q)||r.match(O))a={mode:"rgb",r:e[1]/255,g:e[2]/255,b:e[3]/255};else{if(!(e=r.match(R)||r.match(z)))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&&k(c[r.toLowerCase()],6)||void 0},function(r){return"transparent"===r?k(0,8):void 0}]},F=function(r){return r<.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)},G=function(r){var e=r.r,a=r.g,t=r.b,n=r.alpha,o={mode:"lrgb",r:F(e),g:F(a),b:F(t)};return void 0!==n&&(o.alpha=n),o},H=function(r){return r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r},J=function(r){var e=r.r,a=r.g,t=r.b,n=r.alpha,o={mode:"rgb",r:H(e),g:H(a),b:H(t)};return void 0!==n&&(o.alpha=n),o},K={mode:"lrgb",output:{rgb:J},input:{rgb:G},keys:["r","g","b","alpha"]};var N=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}},Q={mode:"hsl",output:{rgb:function(r){var e=r.h,a=r.s,t=r.l,n=r.alpha;e=p(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}},keys:["h","s","l","alpha"],parsers:[function(r){if("string"==typeof r){var e=r.match(S)||r.match(I);if(e){var a={mode:"hsl",h:void 0===e[3]?N(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}}}]};function T(r){var e=r.h,a=r.s,t=r.v,n=r.alpha;e=p(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 U(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 V={mode:"hsv",output:{rgb:T},input:{rgb:U},keys:["h","s","v","alpha"]};var W={mode:"hsi",output:{rgb:function(r){var e=r.h,a=r.s,t=r.i,n=r.alpha;e=p(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}},keys:["h","s","i","alpha"]};var X={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 T({h:e,s:1===t?1:1-a/(1-t),v:1-t,alpha:n})}},input:{rgb:function(r){var e=U(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}}},keys:["h","w","b","alpha"],parsers:[function(r){if("string"==typeof r){var e=r.match(C);if(e){var a={mode:"hwb",h:void 0===e[3]?N(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}}}]},Y=Math.pow(29,3)/Math.pow(3,3),Z=Math.pow(6,3)/Math.pow(29,3),_=function(r){return Math.pow(r,3)>Z?Math.pow(r,3):(116*r-16)/Y},rr=function(r){var e,a,t,n,o,i=function(r){var e=r.x,a=r.y,t=r.z;return J({r:3.2404542*e-1.5371385*a-.4985314*t,g:-.969266*e+1.8760108*a+.041556*t,b:.0556434*e-.2040259*a+1.0572252*t})}((a=(e=r).l,t=e.a,o=(n=(a+16)/116)-e.b/200,{x:.95047*_(t/500+n),y:1*_(n),z:1.08883*_(o)}));return i.mode="rgb",void 0!==r.alpha&&(i.alpha=r.alpha),i},er=function(r){return r>Z?Math.cbrt(r):(Y*r+16)/116},ar=function(r){var e,a,t,n,o,i,l=(e=function(r){var e=G(r),a=e.r,t=e.g,n=e.b;return{x:.4124564*a+.3575761*t+.1804375*n,y:.2126729*a+.7151522*t+.072175*n,z:.0193339*a+.119192*t+.9503041*n}}(r),a=e.x,t=e.y,n=e.z,o=er(a/.95047),{l:116*(i=er(t/1))-16,a:500*(o-i),b:200*(i-er(n/1.08883))});return l.mode="lab",void 0!==r.alpha&&(l.alpha=r.alpha),l},tr={mode:"lab",output:{rgb:rr},input:{rgb:ar},keys:["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(B)))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}]},nr=h(4),or=function(r){var e=r.l,a=r.a,t=r.b,n=r.alpha,o=nr(Math.sqrt(a*a+t*t)),i={mode:"lch",l:e,c:o};return o&&(i.h=p(180*Math.atan2(t,a)/Math.PI)),void 0!==n&&(i.alpha=n),i},ir=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},lr={mode:"lch",output:{lab:ir,rgb:function(r){return rr(ir(r))}},input:{rgb:function(r){return or(ar(r))},lch:or},keys:["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]?N(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}}]};t(D),t(K),t(Q),t(V),t(W),t(X),t(tr),t(lr);var hr=l("rgb"),ur=l("lrgb"),sr=l("hsl"),dr=l("hsv"),br=l("hsi"),gr=l("hwb"),cr=l("lab"),pr=l("lch"),vr=hr,fr=Object.freeze({hsl:sr,hsv:dr,hsi:br,hwb:gr,rgb:hr,lab:cr,lch:pr,lrgb:ur,css:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"rgb";return function(e){var a=d(b(e));return"hex"===r?"#"+(1<<24|a.r<<16|a.g<<8|a.b).toString(16).slice(1):"rgb"===r?void 0===a.alpha||255===a.alpha?"rgb("+a.r+", "+a.g+", "+a.b+")":"rgba("+a.r+", "+a.g+", "+a.b+", "+g(a.alpha)+")":void 0}},converter:l,brighten:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",a=l(e);return function(t){var n=l(t.mode),o=Object.assign({},a(t));switch(e){case"rgb":case"lrgb":o.r=Math.pow(o.r,2.2/r),o.g=Math.pow(o.g,2.2/r),o.b=Math.pow(o.b,2.2/r);break;case"hsl":case"lab":case"lch":o.l*=exp;break;case"hsv":o.v*=exp;break;case"hsi":o.i*=exp}return n(o)}},round:h,parse:n,named:c,transform:s,interpolate:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb";if(!(r.length<2)){var a=r.map(l(e));return function(r){var t=(r=Math.min(Math.max(0,r),1))*(a.length-1),n=Math.floor(t),o=a[n],i=1===r?a[n]:a[n+1],l=t-n;return s(function(r,e){return("h"===e?m:"alpha"===e?y:f)(o[e],i[e],l)})({mode:e})}}},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},default:vr});return Object.assign(vr,fr),vr}); |
@@ -365,3 +365,3 @@ var converters = {}; | ||
var gamma = beta > 0 ? 1 - beta : 1 / (1 + beta); | ||
// let gamma = beta > 0 ? 1 - beta : 1 / (1 + beta); | ||
var conv = converter(mode); | ||
@@ -377,5 +377,5 @@ | ||
case 'lrgb': | ||
res.r = Math.pow(res.r, 2.2 / gamma); | ||
res.g = Math.pow(res.g, 2.2 / gamma); | ||
res.b = Math.pow(res.b, 2.2 / gamma); | ||
res.r = Math.pow(res.r, 2.2 / beta); | ||
res.g = Math.pow(res.g, 2.2 / beta); | ||
res.b = Math.pow(res.b, 2.2 / beta); | ||
break; | ||
@@ -382,0 +382,0 @@ case 'hsl': |
{ | ||
"name": "culori", | ||
"version": "0.2.55", | ||
"version": "0.2.56", | ||
"main": "build/culori.js", | ||
@@ -5,0 +5,0 @@ "module": "build/index.js", |
@@ -5,3 +5,3 @@ import converter from './converter'; | ||
let gamma = beta > 0 ? 1 - beta : 1 / (1 + beta); | ||
// let gamma = beta > 0 ? 1 - beta : 1 / (1 + beta); | ||
let conv = converter(mode); | ||
@@ -17,5 +17,5 @@ | ||
case 'lrgb': | ||
res.r = Math.pow(res.r, 2.2 / gamma); | ||
res.g = Math.pow(res.g, 2.2 / gamma); | ||
res.b = Math.pow(res.b, 2.2 / gamma); | ||
res.r = Math.pow(res.r, 2.2 / beta); | ||
res.g = Math.pow(res.g, 2.2 / beta); | ||
res.b = Math.pow(res.b, 2.2 / beta); | ||
break; | ||
@@ -22,0 +22,0 @@ case 'hsl': |
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
109841