colord
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -0,4 +1,10 @@ | ||
### 1.7.0 | ||
- New `getFormat` utility | ||
- Support HWB color strings (CSS functional notation) | ||
- Clamp LAB values as defined in CSS Color Level 4 specs | ||
### 1.6.0 | ||
- Improvement: You can now use every angle unit supported by CSS (`deg`, `rad`, `grad`, `turn`). | ||
- Improvement: You can now use every angle unit supported by CSS (`deg`, `rad`, `grad`, `turn`) | ||
@@ -5,0 +11,0 @@ ### 1.5.0 |
export { colord, Colord } from "./colord"; | ||
export { extend, Plugin } from "./extend"; | ||
export { getFormat } from "./parse"; | ||
export { random } from "./random"; | ||
export { HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, LabColor, LabaColor, LchColor, LchaColor, RgbColor, RgbaColor, XyzColor, XyzaColor, AnyColor, } from "./types"; |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:!0});var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},e=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},u={grad:.9,turn:360,rad:360/(2*Math.PI)},a=function(r){return{r:n(r.r,0,255),g:n(r.g,0,255),b:n(r.b,0,255),a:n(r.a)}},o=function(r){return{r:t(r.r),g:t(r.g),b:t(r.b),a:t(r.a,2)}},i=/^\s*#?([0-9a-f]{3,8})\s*$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},b=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},h=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),b=a%6;return{r:255*[e,i,o,o,s,e][b],g:255*[s,e,e,i,o,o][b],b:255*[o,o,s,e,e,i][b],a:u}},g=function(r){return{h:e(r.h),s:n(r.s,0,100),l:n(r.l,0,100),a:n(r.a)}},f=function(r){return{h:t(r.h),s:t(r.s),l:t(r.l),a:t(r.a,2)}},c=function(r){return h((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},p=function(r){return{h:(t=b(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,d=/rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,v={string:[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?parseInt(r[3]+r[3],16)/255:1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?parseInt(r.substr(6,2),16)/255:1}:null:null},function(r){var t=d.exec(r);return t?a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},function(r){var t=l.exec(r);if(!t)return null;var n,e,a=g({h:(n=t[1],e=t[2],void 0===e&&(e="deg"),Number(n)*(u[e]||1)),s:Number(t[3]),l:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return c(a)}],object:[function(t){var n=t.r,e=t.g,u=t.b,o=t.a,i=void 0===o?1:o;return r(n)&&r(e)&&r(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},function(t){var n=t.h,e=t.s,u=t.l,a=t.a,o=void 0===a?1:a;if(!r(n)||!r(e)||!r(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return c(i)},function(t){var u=t.h,a=t.s,o=t.v,i=t.a,s=void 0===i?1:i;if(!r(u)||!r(a)||!r(o))return null;var b=function(r){return{h:e(r.h),s:n(r.s,0,100),v:n(r.v,0,100),a:n(r.a)}}({h:Number(u),s:Number(a),v:Number(o),a:Number(s)});return h(b)}]},m=function(r,t){for(var n=0;n<t.length;n++){var e=t[n](r);if(e)return e}return null},y=function(r,t){var e=p(r);return{h:e.h,s:n(e.s+100*t,0,100),l:e.l,a:e.a}},N=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},x=function(r,t){var e=p(r);return{h:e.h,s:e.s,l:n(e.l+100*t,0,100),a:e.a}},M=function(){function r(r){this.parsed=function(r){return"string"==typeof r?m(r,v.string):"object"==typeof r&&null!==r?m(r,v.object):null}(r),this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return t(N(this.rgba),2)},r.prototype.isDark=function(){return N(this.rgba)<.5},r.prototype.isLight=function(){return N(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),n=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(t(255*a)):"","#"+s(n)+s(e)+s(u)+i;var r,n,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return f(p(this.rgba))},r.prototype.toHslString=function(){return r=f(p(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=b(this.rgba),{h:t(r.h),s:t(r.s),v:t(r.v),a:t(r.a,2)};var r},r.prototype.invert=function(){return I({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),I(y(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),I(y(this.rgba,-r))},r.prototype.grayscale=function(){return I(y(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),I(x(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),I(x(this.rgba,-r))},r.prototype.alpha=function(r){return"number"==typeof r?I({r:(n=this.rgba).r,g:n.g,b:n.b,a:r}):t(this.rgba.a,2);var n},r}(),I=function(r){return r instanceof M?r:new M(r)},j=[];exports.Colord=M,exports.colord=I,exports.extend=function(r){r.forEach(function(r){j.indexOf(r)<0&&(r(M,v),j.push(r))})},exports.random=function(){return new M({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; | ||
Object.defineProperty(exports,"__esModule",{value:!0});var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},e=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},u={grad:.9,turn:360,rad:360/(2*Math.PI)},o=function(r){return{r:n(r.r,0,255),g:n(r.g,0,255),b:n(r.b,0,255),a:n(r.a)}},a=function(r){return{r:t(r.r),g:t(r.g),b:t(r.b),a:t(r.a,2)}},i=/^\s*#?([0-9a-f]{3,8})\s*$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},b=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,o=Math.max(t,n,e),a=o-Math.min(t,n,e),i=a?o===t?(n-e)/a:o===n?2+(e-t)/a:4+(t-n)/a:0;return{h:60*(i<0?i+6:i),s:o?a/o*100:0,v:o/255*100,a:u}},h=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var o=Math.floor(t),a=e*(1-n),i=e*(1-(t-o)*n),s=e*(1-(1-t+o)*n),b=o%6;return{r:255*[e,i,a,a,s,e][b],g:255*[s,e,e,i,a,a][b],b:255*[a,a,s,e,e,i][b],a:u}},g=function(r){return{h:e(r.h),s:n(r.s,0,100),l:n(r.l,0,100),a:n(r.a)}},f=function(r){return{h:t(r.h),s:t(r.s),l:t(r.l),a:t(r.a,2)}},c=function(r){return h((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},l=function(r){return{h:(t=b(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},p=/hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,v=/rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,d={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?parseInt(r[3]+r[3],16)/255:1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?parseInt(r.substr(6,2),16)/255:1}:null:null},"hex"],[function(r){var t=v.exec(r);return t?o({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=p.exec(r);if(!t)return null;var n,e,o=g({h:(n=t[1],e=t[2],void 0===e&&(e="deg"),Number(n)*(u[e]||1)),s:Number(t[3]),l:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return c(o)},"hsl"]],object:[[function(t){var n=t.r,e=t.g,u=t.b,a=t.a,i=void 0===a?1:a;return r(n)&&r(e)&&r(u)?o({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(t){var n=t.h,e=t.s,u=t.l,o=t.a,a=void 0===o?1:o;if(!r(n)||!r(e)||!r(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(a)});return c(i)},"hsl"],[function(t){var u=t.h,o=t.s,a=t.v,i=t.a,s=void 0===i?1:i;if(!r(u)||!r(o)||!r(a))return null;var b=function(r){return{h:e(r.h),s:n(r.s,0,100),v:n(r.v,0,100),a:n(r.a)}}({h:Number(u),s:Number(o),v:Number(a),a:Number(s)});return h(b)},"hsv"]]},m=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},y=function(r){return"string"==typeof r?m(r,d.string):"object"==typeof r&&null!==r?m(r,d.object):[null,void 0]},N=function(r,t){var e=l(r);return{h:e.h,s:n(e.s+100*t,0,100),l:e.l,a:e.a}},x=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},M=function(r,t){var e=l(r);return{h:e.h,s:e.s,l:n(e.l+100*t,0,100),a:e.a}},I=function(){function r(r){this.parsed=y(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return t(x(this.rgba),2)},r.prototype.isDark=function(){return x(this.rgba)<.5},r.prototype.isLight=function(){return x(this.rgba)>=.5},r.prototype.toHex=function(){return r=a(this.rgba),n=r.r,e=r.g,u=r.b,i=(o=r.a)<1?s(t(255*o)):"","#"+s(n)+s(e)+s(u)+i;var r,n,e,u,o,i},r.prototype.toRgb=function(){return a(this.rgba)},r.prototype.toRgbString=function(){return r=a(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return f(l(this.rgba))},r.prototype.toHslString=function(){return r=f(l(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=b(this.rgba),{h:t(r.h),s:t(r.s),v:t(r.v),a:t(r.a,2)};var r},r.prototype.invert=function(){return j({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),j(N(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),j(N(this.rgba,-r))},r.prototype.grayscale=function(){return j(N(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),j(M(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),j(M(this.rgba,-r))},r.prototype.alpha=function(r){return"number"==typeof r?j({r:(n=this.rgba).r,g:n.g,b:n.b,a:r}):t(this.rgba.a,2);var n},r}(),j=function(r){return r instanceof I?r:new I(r)},H=[];exports.Colord=I,exports.colord=j,exports.extend=function(r){r.forEach(function(r){H.indexOf(r)<0&&(r(I,d),H.push(r))})},exports.getFormat=function(r){return y(r)[1]},exports.random=function(){return new I({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; |
{ | ||
"name": "colord", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "👑 A tiny yet powerful tool for high-performance color manipulations and conversions", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,4 +0,8 @@ | ||
import { Parsers, Input, RgbaColor } from "./types"; | ||
import { Parsers, ParseResult, Input, Format } from "./types"; | ||
export declare const parsers: Parsers; | ||
/** Tries to convert an incoming value into RGBA color by going through all color model parsers */ | ||
export declare const parse: (input: Input) => RgbaColor | null; | ||
export declare const parse: (input: Input) => ParseResult | [null, undefined]; | ||
/** | ||
* Returns a color model name for the input passed to the function. | ||
*/ | ||
export declare const getFormat: (input: Input) => Format | undefined; |
@@ -5,3 +5,12 @@ import { HwbaColor } from "../types"; | ||
interface Colord { | ||
/** | ||
* Converts a color to HWB (Hue-Whiteness-Blackness) color space and returns an object. | ||
* https://en.wikipedia.org/wiki/HWB_color_model | ||
*/ | ||
toHwb(): HwbaColor; | ||
/** | ||
* Converts a color to HWB (Hue-Whiteness-Blackness) color space and returns a string. | ||
* https://www.w3.org/TR/css-color-4/#the-hwb-notation | ||
*/ | ||
toHwbString(): string; | ||
} | ||
@@ -12,4 +21,5 @@ } | ||
* https://en.wikipedia.org/wiki/HWB_color_model | ||
* https://www.w3.org/TR/css-color-4/#the-hwb-notation | ||
*/ | ||
declare const hwbPlugin: Plugin; | ||
export default hwbPlugin; |
@@ -1,1 +0,1 @@ | ||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},a=function(r){return{h:function(r){var n=r.r,t=r.g,a=r.b,u=r.a,o=Math.max(n,t,a),e=o-Math.min(n,t,a),b=e?o===n?(t-a)/e:o===t?2+(a-n)/e:4+(n-t)/e:0;return{h:60*(b<0?b+6:b),s:o?e/o*100:0,v:o/255*100,a:u}}(r).h,w:Math.min(r.r,r.g,r.b)/255*100,b:100-Math.max(r.r,r.g,r.b)/255*100,a:r.a}},u=function(r){return function(r){var n=r.h,t=r.s,a=r.v,u=r.a;n=n/360*6,t/=100,a/=100;var o=Math.floor(n),e=a*(1-t),b=a*(1-(n-o)*t),h=a*(1-(1-n+o)*t),i=o%6;return{r:255*[a,b,e,e,h,a][i],g:255*[h,a,a,b,e,e][i],b:255*[e,e,h,a,a,b][i],a:u}}({h:r.h,s:100===r.b?0:100-r.w/(100-r.b)*100,v:100-r.b,a:r.a})},o=function(n){var a=n.h,o=n.w,e=n.b,b=n.a,h=void 0===b?1:b;if(!r(a)||!r(o)||!r(e))return null;var i=function(r){return{h:t(r.h,0,360),w:t(r.w,0,100),b:t(r.b,0,100),a:t(r.a)}}({h:Number(a),w:Number(o),b:Number(e),a:Number(h)});return u(i)};module.exports=function(r,t){r.prototype.toHwb=function(){return r=a(this.rgba),{h:n(r.h),w:n(r.w),b:n(r.b),a:n(r.a,2)};var r},t.object.push(o)}; | ||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},u={grad:.9,turn:360,rad:360/(2*Math.PI)},a=function(r){return{h:(n=r.h,(n=isFinite(n)?n%360:0)>0?n:n+360),w:t(r.w,0,100),b:t(r.b,0,100),a:t(r.a)};var n},e=function(r){return{h:n(r.h),w:n(r.w),b:n(r.b),a:n(r.a,2)}},o=function(r){return{h:function(r){var n=r.r,t=r.g,u=r.b,a=r.a,e=Math.max(n,t,u),o=e-Math.min(n,t,u),b=o?e===n?(t-u)/o:e===t?2+(u-n)/o:4+(n-t)/o:0;return{h:60*(b<0?b+6:b),s:e?o/e*100:0,v:e/255*100,a:a}}(r).h,w:Math.min(r.r,r.g,r.b)/255*100,b:100-Math.max(r.r,r.g,r.b)/255*100,a:r.a}},b=function(r){return function(r){var n=r.h,t=r.s,u=r.v,a=r.a;n=n/360*6,t/=100,u/=100;var e=Math.floor(n),o=u*(1-t),b=u*(1-(n-e)*t),i=u*(1-(1-n+e)*t),h=e%6;return{r:255*[u,b,o,o,i,u][h],g:255*[i,u,u,b,o,o][h],b:255*[o,o,i,u,u,b][h],a:a}}({h:r.h,s:100===r.b?0:100-r.w/(100-r.b)*100,v:100-r.b,a:r.a})},i=function(n){var t=n.h,u=n.w,e=n.b,o=n.a,i=void 0===o?1:o;if(!r(t)||!r(u)||!r(e))return null;var h=a({h:Number(t),w:Number(u),b:Number(e),a:Number(i)});return b(h)},h=/hwba?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,d=function(r){var n=h.exec(r);if(!n)return null;var t,e,o=a({h:(t=n[1],e=n[2],void 0===e&&(e="deg"),Number(t)*(u[e]||1)),w:Number(n[3]),b:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return b(o)};module.exports=function(r,n){r.prototype.toHwb=function(){return e(o(this.rgba))},r.prototype.toHwbString=function(){return r=e(o(this.rgba)),n=r.h,t=r.w,u=r.b,(a=r.a)<1?"hwb("+n+", "+t+"%, "+u+"%, "+a+")":"hwb("+n+", "+t+"%, "+u+"%)";var r,n,t,u,a},n.string.push([d,"hwb"]),n.object.push([i,"hwb"])}; |
@@ -1,1 +0,1 @@ | ||
var a=function(a){return"string"==typeof a?a.length>0:"number"==typeof a},r=function(a,r,t){return void 0===r&&(r=0),void 0===t&&(t=Math.pow(10,r)),Math.round(t*a)/t+0},t=function(a,r,t){return void 0===r&&(r=0),void 0===t&&(t=1),a>t?t:a>r?a:r},n=function(a){var r=a/255;return r<.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)},u=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},o=96.422,e=100,b=82.521,h=function(a){var r,n,o={x:.9555766*(r=a).x+-.0230393*r.y+.0631636*r.z,y:-.0282895*r.x+1.0099416*r.y+.0210077*r.z,z:.0122982*r.x+-.020483*r.y+1.3299098*r.z};return n={r:u(.032404542*o.x-.015371385*o.y-.004985314*o.z),g:u(-.00969266*o.x+.018760108*o.y+41556e-8*o.z),b:u(556434e-9*o.x-.002040259*o.y+.010572252*o.z),a:a.a},{r:t(n.r,0,255),g:t(n.g,0,255),b:t(n.b,0,255),a:t(n.a)}},l=function(a){var r=n(a.r),u=n(a.g),h=n(a.b);return function(a){return{x:t(a.x,0,o),y:t(a.y,0,e),z:t(a.z,0,b),a:t(a.a)}}(function(a){return{x:1.0478112*a.x+.0228866*a.y+-.050127*a.z,y:.0295424*a.x+.9904844*a.y+-.0170491*a.z,z:-.0092345*a.x+.0150436*a.y+.7521316*a.z,a:a.a}}({x:100*(.4124564*r+.3575761*u+.1804375*h),y:100*(.2126729*r+.7151522*u+.072175*h),z:100*(.0193339*r+.119192*u+.9503041*h),a:a.a}))},i=216/24389,p=24389/27,y=function(r){var n=r.l,u=r.a,o=r.b,e=r.alpha,b=void 0===e?1:e;if(!a(n)||!a(u)||!a(o))return null;var h=function(a){return{l:t(a.l,0,100),a:t(a.a,-128,128),b:t(a.b,-128,128),alpha:t(a.alpha)}}({l:Number(n),a:Number(u),b:Number(o),alpha:Number(b)});return c(h)},c=function(a){var r=(a.l+16)/116,t=a.a/500+r,n=r-a.b/200;return h({x:(Math.pow(t,3)>i?Math.pow(t,3):(116*t-16)/p)*o,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/p)*e,z:(Math.pow(n,3)>i?Math.pow(n,3):(116*n-16)/p)*b,a:a.alpha})};module.exports=function(a,t){a.prototype.toLab=function(){return t=l(this.rgba),u=t.y/e,h=t.z/b,n=(n=t.x/o)>i?Math.cbrt(n):(p*n+16)/116,a={l:116*(u=u>i?Math.cbrt(u):(p*u+16)/116)-16,a:500*(n-u),b:200*(u-(h=h>i?Math.cbrt(h):(p*h+16)/116)),alpha:t.a},{l:r(a.l,2),a:r(a.a,2),b:r(a.b,2),alpha:r(a.alpha,2)};var a,t,n,u,h},t.object.push(y)}; | ||
var a=function(a){return"string"==typeof a?a.length>0:"number"==typeof a},r=function(a,r,t){return void 0===r&&(r=0),void 0===t&&(t=Math.pow(10,r)),Math.round(t*a)/t+0},t=function(a,r,t){return void 0===r&&(r=0),void 0===t&&(t=1),a>t?t:a>r?a:r},n=function(a){var r=a/255;return r<.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)},u=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},o=96.422,e=100,b=82.521,l=function(a){var r,n,o={x:.9555766*(r=a).x+-.0230393*r.y+.0631636*r.z,y:-.0282895*r.x+1.0099416*r.y+.0210077*r.z,z:.0122982*r.x+-.020483*r.y+1.3299098*r.z};return n={r:u(.032404542*o.x-.015371385*o.y-.004985314*o.z),g:u(-.00969266*o.x+.018760108*o.y+41556e-8*o.z),b:u(556434e-9*o.x-.002040259*o.y+.010572252*o.z),a:a.a},{r:t(n.r,0,255),g:t(n.g,0,255),b:t(n.b,0,255),a:t(n.a)}},h=function(a){var r=n(a.r),u=n(a.g),l=n(a.b);return function(a){return{x:t(a.x,0,o),y:t(a.y,0,e),z:t(a.z,0,b),a:t(a.a)}}(function(a){return{x:1.0478112*a.x+.0228866*a.y+-.050127*a.z,y:.0295424*a.x+.9904844*a.y+-.0170491*a.z,z:-.0092345*a.x+.0150436*a.y+.7521316*a.z,a:a.a}}({x:100*(.4124564*r+.3575761*u+.1804375*l),y:100*(.2126729*r+.7151522*u+.072175*l),z:100*(.0193339*r+.119192*u+.9503041*l),a:a.a}))},i=216/24389,p=24389/27,y=function(r){var n=r.l,u=r.a,o=r.b,e=r.alpha,b=void 0===e?1:e;if(!a(n)||!a(u)||!a(o))return null;var l=function(a){return{l:t(a.l,0,400),a:a.a,b:a.b,alpha:t(a.alpha)}}({l:Number(n),a:Number(u),b:Number(o),alpha:Number(b)});return c(l)},c=function(a){var r=(a.l+16)/116,t=a.a/500+r,n=r-a.b/200;return l({x:(Math.pow(t,3)>i?Math.pow(t,3):(116*t-16)/p)*o,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/p)*e,z:(Math.pow(n,3)>i?Math.pow(n,3):(116*n-16)/p)*b,a:a.alpha})};module.exports=function(a,t){a.prototype.toLab=function(){return t=h(this.rgba),u=t.y/e,l=t.z/b,n=(n=t.x/o)>i?Math.cbrt(n):(p*n+16)/116,a={l:116*(u=u>i?Math.cbrt(u):(p*u+16)/116)-16,a:500*(n-u),b:200*(u-(l=l>i?Math.cbrt(l):(p*l+16)/116)),alpha:t.a},{l:r(a.l,2),a:r(a.a,2),b:r(a.b,2),alpha:r(a.alpha,2)};var a,t,n,u,l},t.object.push([y,"lab"])}; |
@@ -1,1 +0,1 @@ | ||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=Math.pow(10,t)),Math.round(a*r)/a+0},a=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=1),r>a?a:r>t?r:t},n={grad:.9,turn:360,rad:360/(2*Math.PI)},u=function(r){var t=r/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},o=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},h=96.422,e=100,c=82.521,i=function(r){var t,n,u={x:.9555766*(t=r).x+-.0230393*t.y+.0631636*t.z,y:-.0282895*t.x+1.0099416*t.y+.0210077*t.z,z:.0122982*t.x+-.020483*t.y+1.3299098*t.z};return n={r:o(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:o(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:o(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:r.a},{r:a(n.r,0,255),g:a(n.g,0,255),b:a(n.b,0,255),a:a(n.a)}},l=function(r){var t=u(r.r),n=u(r.g),o=u(r.b);return function(r){return{x:a(r.x,0,h),y:a(r.y,0,e),z:a(r.z,0,c),a:a(r.a)}}(function(r){return{x:1.0478112*r.x+.0228866*r.y+-.050127*r.z,y:.0295424*r.x+.9904844*r.y+-.0170491*r.z,z:-.0092345*r.x+.0150436*r.y+.7521316*r.z,a:r.a}}({x:100*(.4124564*t+.3575761*n+.1804375*o),y:100*(.2126729*t+.7151522*n+.072175*o),z:100*(.0193339*t+.119192*n+.9503041*o),a:r.a}))},b=216/24389,d=24389/27,f=function(r){return{l:a(r.l,0,100),c:r.c,h:(t=r.h,(t=isFinite(t)?t%360:0)>0?t:t+360),a:r.a};var t},p=function(r){return{l:t(r.l,2),c:t(r.c,2),h:t(r.h,2),a:t(r.a,2)}},v=function(t){var a=t.l,n=t.c,u=t.h,o=t.a,h=void 0===o?1:o;if(!r(a)||!r(n)||!r(u))return null;var e=f({l:Number(a),c:Number(n),h:Number(u),a:Number(h)});return M(e)},y=function(r){var a=function(r){var t=l(r),a=t.x/h,n=t.y/e,u=t.z/c;return a=a>b?Math.cbrt(a):(d*a+16)/116,{l:116*(n=n>b?Math.cbrt(n):(d*n+16)/116)-16,a:500*(a-n),b:200*(n-(u=u>b?Math.cbrt(u):(d*u+16)/116)),alpha:t.a}}(r),n=t(a.a,3),u=t(a.b,3),o=Math.atan2(u,n)/Math.PI*180;return{l:a.l,c:Math.sqrt(n*n+u*u),h:o<0?o+360:o,a:a.alpha}},M=function(r){return t={l:r.l,a:r.c*Math.cos(r.h*Math.PI/180),b:r.c*Math.sin(r.h*Math.PI/180),alpha:r.a},n=t.a/500+(a=(t.l+16)/116),u=a-t.b/200,i({x:(Math.pow(n,3)>b?Math.pow(n,3):(116*n-16)/d)*h,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/d)*e,z:(Math.pow(u,3)>b?Math.pow(u,3):(116*u-16)/d)*c,a:t.alpha});var t,a,n,u},x=/lcha?\(?\s*(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)[,\s]+(-?\d*\.?\d+)(deg|rad|grad|turn)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,s=function(r){var t=x.exec(r);if(!t)return null;var a,u,o=f({l:Number(t[1]),c:Number(t[2]),h:(a=t[3],u=t[4],void 0===u&&(u="deg"),Number(a)*(n[u]||1)),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return M(o)};module.exports=function(r,t){r.prototype.toLch=function(){return p(y(this.rgba))},r.prototype.toLchString=function(){return r=p(y(this.rgba)),t=r.l,a=r.c,n=r.h,(u=r.a)<1?"lch("+t+"% "+a+" "+n+" / "+u+")":"lch("+t+"% "+a+" "+n+")";var r,t,a,n,u},t.string.push(s),t.object.push(v)}; | ||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=Math.pow(10,t)),Math.round(a*r)/a+0},a=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=1),r>a?a:r>t?r:t},n={grad:.9,turn:360,rad:360/(2*Math.PI)},u=function(r){var t=r/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},h=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},o=96.422,e=100,c=82.521,i=function(r){var t,n,u={x:.9555766*(t=r).x+-.0230393*t.y+.0631636*t.z,y:-.0282895*t.x+1.0099416*t.y+.0210077*t.z,z:.0122982*t.x+-.020483*t.y+1.3299098*t.z};return n={r:h(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:h(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:h(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:r.a},{r:a(n.r,0,255),g:a(n.g,0,255),b:a(n.b,0,255),a:a(n.a)}},l=function(r){var t=u(r.r),n=u(r.g),h=u(r.b);return function(r){return{x:a(r.x,0,o),y:a(r.y,0,e),z:a(r.z,0,c),a:a(r.a)}}(function(r){return{x:1.0478112*r.x+.0228866*r.y+-.050127*r.z,y:.0295424*r.x+.9904844*r.y+-.0170491*r.z,z:-.0092345*r.x+.0150436*r.y+.7521316*r.z,a:r.a}}({x:100*(.4124564*t+.3575761*n+.1804375*h),y:100*(.2126729*t+.7151522*n+.072175*h),z:100*(.0193339*t+.119192*n+.9503041*h),a:r.a}))},b=216/24389,d=24389/27,f=function(r){return{l:a(r.l,0,100),c:r.c,h:(t=r.h,(t=isFinite(t)?t%360:0)>0?t:t+360),a:r.a};var t},p=function(r){return{l:t(r.l,2),c:t(r.c,2),h:t(r.h,2),a:t(r.a,2)}},v=function(t){var a=t.l,n=t.c,u=t.h,h=t.a,o=void 0===h?1:h;if(!r(a)||!r(n)||!r(u))return null;var e=f({l:Number(a),c:Number(n),h:Number(u),a:Number(o)});return M(e)},y=function(r){var a=function(r){var t=l(r),a=t.x/o,n=t.y/e,u=t.z/c;return a=a>b?Math.cbrt(a):(d*a+16)/116,{l:116*(n=n>b?Math.cbrt(n):(d*n+16)/116)-16,a:500*(a-n),b:200*(n-(u=u>b?Math.cbrt(u):(d*u+16)/116)),alpha:t.a}}(r),n=t(a.a,3),u=t(a.b,3),h=Math.atan2(u,n)/Math.PI*180;return{l:a.l,c:Math.sqrt(n*n+u*u),h:h<0?h+360:h,a:a.alpha}},M=function(r){return t={l:r.l,a:r.c*Math.cos(r.h*Math.PI/180),b:r.c*Math.sin(r.h*Math.PI/180),alpha:r.a},n=t.a/500+(a=(t.l+16)/116),u=a-t.b/200,i({x:(Math.pow(n,3)>b?Math.pow(n,3):(116*n-16)/d)*o,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/d)*e,z:(Math.pow(u,3)>b?Math.pow(u,3):(116*u-16)/d)*c,a:t.alpha});var t,a,n,u},x=/lcha?\(?\s*(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)[,\s]+(-?\d*\.?\d+)(deg|rad|grad|turn)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,s=function(r){var t=x.exec(r);if(!t)return null;var a,u,h=f({l:Number(t[1]),c:Number(t[2]),h:(a=t[3],u=t[4],void 0===u&&(u="deg"),Number(a)*(n[u]||1)),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return M(h)};module.exports=function(r,t){r.prototype.toLch=function(){return p(y(this.rgba))},r.prototype.toLchString=function(){return r=p(y(this.rgba)),t=r.l,a=r.c,n=r.h,(u=r.a)<1?"lch("+t+"% "+a+" "+n+" / "+u+")":"lch("+t+"% "+a+" "+n+")";var r,t,a,n,u},t.string.push([s,"lch"]),t.object.push([v,"lch"])}; |
@@ -1,1 +0,1 @@ | ||
var a=function(a,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),a>n?n:a>t?a:t},t=function(a){var t=a/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},n=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},r=96.422,o=100,u=82.521,e=function(t){var r,o,u={x:.9555766*(r=t).x+-.0230393*r.y+.0631636*r.z,y:-.0282895*r.x+1.0099416*r.y+.0210077*r.z,z:.0122982*r.x+-.020483*r.y+1.3299098*r.z};return o={r:n(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:n(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:n(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:t.a},{r:a(o.r,0,255),g:a(o.g,0,255),b:a(o.b,0,255),a:a(o.a)}},h=function(n){var e=t(n.r),h=t(n.g),i=t(n.b);return function(t){return{x:a(t.x,0,r),y:a(t.y,0,o),z:a(t.z,0,u),a:a(t.a)}}(function(a){return{x:1.0478112*a.x+.0228866*a.y+-.050127*a.z,y:.0295424*a.x+.9904844*a.y+-.0170491*a.z,z:-.0092345*a.x+.0150436*a.y+.7521316*a.z,a:a.a}}({x:100*(.4124564*e+.3575761*h+.1804375*i),y:100*(.2126729*e+.7151522*h+.072175*i),z:100*(.0193339*e+.119192*h+.9503041*i),a:n.a}))},i=216/24389,l=24389/27,x=function(a){var t=h(a),n=t.x/r,e=t.y/o,x=t.z/u;return n=n>i?Math.cbrt(n):(l*n+16)/116,{l:116*(e=e>i?Math.cbrt(e):(l*e+16)/116)-16,a:500*(n-e),b:200*(e-(x=x>i?Math.cbrt(x):(l*x+16)/116)),alpha:t.a}},p=function(t,n,h){var p,y=x(t),b=x(n);return function(a){var t=(a.l+16)/116,n=a.a/500+t,h=t-a.b/200;return e({x:(Math.pow(n,3)>i?Math.pow(n,3):(116*n-16)/l)*r,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/l)*o,z:(Math.pow(h,3)>i?Math.pow(h,3):(116*h-16)/l)*u,a:a.alpha})}({l:a((p={l:y.l*(1-h)+b.l*h,a:y.a*(1-h)+b.a*h,b:y.b*(1-h)+b.b*h,alpha:y.alpha*(1-h)+b.alpha*h}).l,0,100),a:a(p.a,-128,128),b:a(p.b,-128,128),alpha:a(p.alpha)})};module.exports=function(a){a.prototype.mix=function(t,n){void 0===n&&(n=.5);var r=t instanceof a?t:new a(t),o=p(this.toRgb(),r.toRgb(),n);return new a(o)}}; | ||
var a=function(a,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),a>n?n:a>t?a:t},t=function(a){var t=a/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},n=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},r=96.422,o=100,u=82.521,e=function(t){var r,o,u={x:.9555766*(r=t).x+-.0230393*r.y+.0631636*r.z,y:-.0282895*r.x+1.0099416*r.y+.0210077*r.z,z:.0122982*r.x+-.020483*r.y+1.3299098*r.z};return o={r:n(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:n(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:n(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:t.a},{r:a(o.r,0,255),g:a(o.g,0,255),b:a(o.b,0,255),a:a(o.a)}},h=function(n){var e=t(n.r),h=t(n.g),i=t(n.b);return function(t){return{x:a(t.x,0,r),y:a(t.y,0,o),z:a(t.z,0,u),a:a(t.a)}}(function(a){return{x:1.0478112*a.x+.0228866*a.y+-.050127*a.z,y:.0295424*a.x+.9904844*a.y+-.0170491*a.z,z:-.0092345*a.x+.0150436*a.y+.7521316*a.z,a:a.a}}({x:100*(.4124564*e+.3575761*h+.1804375*i),y:100*(.2126729*e+.7151522*h+.072175*i),z:100*(.0193339*e+.119192*h+.9503041*i),a:n.a}))},i=216/24389,l=24389/27,x=function(a){var t=h(a),n=t.x/r,e=t.y/o,x=t.z/u;return n=n>i?Math.cbrt(n):(l*n+16)/116,{l:116*(e=e>i?Math.cbrt(e):(l*e+16)/116)-16,a:500*(n-e),b:200*(e-(x=x>i?Math.cbrt(x):(l*x+16)/116)),alpha:t.a}},p=function(t,n,h){var p,y=x(t),b=x(n);return function(a){var t=(a.l+16)/116,n=a.a/500+t,h=t-a.b/200;return e({x:(Math.pow(n,3)>i?Math.pow(n,3):(116*n-16)/l)*r,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/l)*o,z:(Math.pow(h,3)>i?Math.pow(h,3):(116*h-16)/l)*u,a:a.alpha})}({l:a((p={l:y.l*(1-h)+b.l*h,a:y.a*(1-h)+b.a*h,b:y.b*(1-h)+b.b*h,alpha:y.alpha*(1-h)+b.alpha*h}).l,0,400),a:p.a,b:p.b,alpha:a(p.alpha)})};module.exports=function(a){a.prototype.mix=function(t,n){void 0===n&&(n=.5);var r=t instanceof a?t:new a(t),o=p(this.toRgb(),r.toRgb(),n);return new a(o)}}; |
@@ -1,1 +0,1 @@ | ||
module.exports=function(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},d={};for(var r in a)d[a[r]]=r;e.prototype.toName=function(){return 0===this.rgba.a?"transparent":d[this.toHex()]||void 0};f.string.push(function(f){var d=f.trim(),r="transparent"===d?"#0000":a[d];return r?new e(r).toRgb():null})}; | ||
module.exports=function(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},d={};for(var r in a)d[a[r]]=r;e.prototype.toName=function(){return 0===this.rgba.a?"transparent":d[this.toHex()]||void 0};f.string.push([function(f){var d=f.trim(),r="transparent"===d?"#0000":a[d];return r?new e(r).toRgb():null},"name"])}; |
@@ -1,1 +0,1 @@ | ||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},u=function(r){var n=r/255;return n<.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)},o=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},a=96.422,e=100,y=82.521,i=function(r){return{x:t(r.x,0,a),y:t(r.y,0,e),z:t(r.z,0,y),a:t(r.a)}},x=function(n){var t=n.x,u=n.y,o=n.z,a=n.a,e=void 0===a?1:a;if(!r(t)||!r(u)||!r(o))return null;var y=i({x:Number(t),y:Number(u),z:Number(o),a:Number(e)});return z(y)},z=function(r){var n,u,a={x:.9555766*(n=r).x+-.0230393*n.y+.0631636*n.z,y:-.0282895*n.x+1.0099416*n.y+.0210077*n.z,z:.0122982*n.x+-.020483*n.y+1.3299098*n.z};return u={r:o(.032404542*a.x-.015371385*a.y-.004985314*a.z),g:o(-.00969266*a.x+.018760108*a.y+41556e-8*a.z),b:o(556434e-9*a.x-.002040259*a.y+.010572252*a.z),a:r.a},{r:t(u.r,0,255),g:t(u.g,0,255),b:t(u.b,0,255),a:t(u.a)}};module.exports=function(r,t){r.prototype.toXyz=function(){return function(r){return{x:n(r.x,2),y:n(r.y,2),z:n(r.z,2),a:n(r.a,2)}}((t=u((r=this.rgba).r),o=u(r.g),a=u(r.b),i({x:1.0478112*(e={x:100*(.4124564*t+.3575761*o+.1804375*a),y:100*(.2126729*t+.7151522*o+.072175*a),z:100*(.0193339*t+.119192*o+.9503041*a),a:r.a}).x+.0228866*e.y+-.050127*e.z,y:.0295424*e.x+.9904844*e.y+-.0170491*e.z,z:-.0092345*e.x+.0150436*e.y+.7521316*e.z,a:e.a})));var r,t,o,a,e},t.object.push(x)}; | ||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},u=function(r){var n=r/255;return n<.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)},o=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},a=96.422,e=100,y=82.521,x=function(r){return{x:t(r.x,0,a),y:t(r.y,0,e),z:t(r.z,0,y),a:t(r.a)}},z=function(n){var t=n.x,u=n.y,o=n.z,a=n.a,e=void 0===a?1:a;if(!r(t)||!r(u)||!r(o))return null;var y=x({x:Number(t),y:Number(u),z:Number(o),a:Number(e)});return i(y)},i=function(r){var n,u,a={x:.9555766*(n=r).x+-.0230393*n.y+.0631636*n.z,y:-.0282895*n.x+1.0099416*n.y+.0210077*n.z,z:.0122982*n.x+-.020483*n.y+1.3299098*n.z};return u={r:o(.032404542*a.x-.015371385*a.y-.004985314*a.z),g:o(-.00969266*a.x+.018760108*a.y+41556e-8*a.z),b:o(556434e-9*a.x-.002040259*a.y+.010572252*a.z),a:r.a},{r:t(u.r,0,255),g:t(u.g,0,255),b:t(u.b,0,255),a:t(u.a)}};module.exports=function(r,t){r.prototype.toXyz=function(){return function(r){return{x:n(r.x,2),y:n(r.y,2),z:n(r.z,2),a:n(r.a,2)}}((t=u((r=this.rgba).r),o=u(r.g),a=u(r.b),x({x:1.0478112*(e={x:100*(.4124564*t+.3575761*o+.1804375*a),y:100*(.2126729*t+.7151522*o+.072175*a),z:100*(.0193339*t+.119192*o+.9503041*a),a:r.a}).x+.0228866*e.y+-.050127*e.z,y:.0295424*e.x+.9904844*e.y+-.0170491*e.z,z:-.0092345*e.x+.0150436*e.y+.7521316*e.z,a:e.a})));var r,t,o,a,e},t.object.push([z,"xyz"])}; |
125
README.md
@@ -73,8 +73,4 @@ <div align="center"> | ||
## API | ||
## Supported Color Models | ||
### Color parsing | ||
#### Accepted input formats | ||
- Hexadecimal strings (including 3, 4 and 8 digit notations) | ||
@@ -85,3 +81,3 @@ - RGB strings and objects | ||
- Color names ([via plugin](#plugins)) | ||
- HWB objects ([via plugin](#plugins)) | ||
- HWB objects and strings ([via plugin](#plugins)) | ||
- LCH objects and strings ([via plugin](#plugins)) | ||
@@ -91,3 +87,16 @@ - LAB objects ([via plugin](#plugins)) | ||
<div><img src="assets/divider.png" width="838" alt="---" /></div> | ||
## API | ||
### Color parsing | ||
<details> | ||
<summary><b><code>colord(input)</code></b></summary> | ||
Parses the given input and creates a new Colord instance. | ||
```js | ||
import { colord } from "colord"; | ||
// String input examples | ||
@@ -112,2 +121,4 @@ colord("FFF"); | ||
Check out the ["Plugins"](#plugins) section for more input format examples. | ||
#### Permissive parser | ||
@@ -124,6 +135,24 @@ | ||
</details> | ||
<details> | ||
<summary><b><code>getFormat(input)</code></b></summary> | ||
Returns a color model name for the input passed to the function. Uses the same parsing system as `colord` function. | ||
```js | ||
import { getFormat } from "colord"; | ||
getFormat("#aabbcc"); // "hex" | ||
getFormat({ r: 13, g: 237, b: 162, a: 0.5 }); // "rgb" | ||
getFormat("hsl(180deg, 50%, 50%)"); // "hsl" | ||
getFormat("WUT?"); // undefined | ||
``` | ||
</details> | ||
### Color conversion | ||
<details> | ||
<summary><b><code>toHex()</code></b></summary> | ||
<summary><b><code>.toHex()</code></b></summary> | ||
@@ -141,3 +170,3 @@ Returns the [hexadecimal representation](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#rgb_colors) of a color. When the alpha channel value of the color is less than 1, it outputs `#rrggbbaa` format instead of `#rrggbb`. | ||
<details> | ||
<summary><b><code>toRgb()</code></b></summary> | ||
<summary><b><code>.toRgb()</code></b></summary> | ||
@@ -152,3 +181,3 @@ ```js | ||
<details> | ||
<summary><b><code>toRgbString()</code></b></summary> | ||
<summary><b><code>.toRgbString()</code></b></summary> | ||
@@ -163,3 +192,3 @@ ```js | ||
<details> | ||
<summary><b><code>toHsl()</code></b></summary> | ||
<summary><b><code>.toHsl()</code></b></summary> | ||
@@ -176,3 +205,3 @@ Converts a color to [HSL color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and returns an object. | ||
<details> | ||
<summary><b><code>toHslString()</code></b></summary> | ||
<summary><b><code>.toHslString()</code></b></summary> | ||
@@ -189,3 +218,3 @@ Converts a color to [HSL color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and expresses it through the [functional notation](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#hsl_colors). | ||
<details> | ||
<summary><b><code>toHsv()</code></b></summary> | ||
<summary><b><code>.toHsv()</code></b></summary> | ||
@@ -202,3 +231,3 @@ Converts a color to [HSV color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and returns an object. | ||
<details> | ||
<summary><b><code>toName()</code></b> (<b>names</b> plugin)</summary> | ||
<summary><b><code>.toName()</code></b> (<b>names</b> plugin)</summary> | ||
@@ -222,3 +251,3 @@ Converts a color to a [CSS keyword](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#color_keywords). Returns `undefined` if the color is not specified in the specs. | ||
<details> | ||
<summary><b><code>toHwb()</code></b> (<b>hwb</b> plugin)</summary> | ||
<summary><b><code>.toHwb()</code></b> (<b>hwb</b> plugin)</summary> | ||
@@ -240,4 +269,22 @@ Converts a color to [HWB (Hue-Whiteness-Blackness)](https://en.wikipedia.org/wiki/HWB_color_model) color space. | ||
<details> | ||
<summary><b><code>toLab()</code></b> (<b>lab</b> plugin)</summary> | ||
<summary><b><code>.toHwbString()</code></b> (<b>hwb</b> plugin)</summary> | ||
Converts a color to [HWB (Hue-Whiteness-Blackness)](https://en.wikipedia.org/wiki/HWB_color_model) color space and expresses it through the [functional notation](https://www.w3.org/TR/css-color-4/#the-hwb-notation). | ||
```js | ||
import { colord, extend } from "colord"; | ||
import hwbPlugin from "colord/plugins/hwb"; | ||
extend([hwbPlugin]); | ||
colord("#999966").toHwbString(); // "hwb(60, 40%, 40%)" | ||
colord("#99ffff").toHwbString(); // "hwb(180, 60%, 0%)" | ||
colord("#003366").alpha(0.5).toHwbString(); // "hwb(210, 0%, 60%, 0.5)" | ||
``` | ||
</details> | ||
<details> | ||
<summary><b><code>.toLab()</code></b> (<b>lab</b> plugin)</summary> | ||
Converts a color to [CIE LAB](https://en.wikipedia.org/wiki/CIELAB_color_space) color space. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code). | ||
@@ -258,3 +305,3 @@ | ||
<details> | ||
<summary><b><code>toLch()</code></b> (<b>lch</b> plugin)</summary> | ||
<summary><b><code>.toLch()</code></b> (<b>lch</b> plugin)</summary> | ||
@@ -276,3 +323,3 @@ Converts a color to [CIE LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code). | ||
<details> | ||
<summary><b><code>toLchString()</code></b> (<b>lch</b> plugin)</summary> | ||
<summary><b><code>.toLchString()</code></b> (<b>lch</b> plugin)</summary> | ||
@@ -294,3 +341,3 @@ Converts a color to [CIE LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space and expresses it through the [functional notation](https://www.w3.org/TR/css-color-4/#specifying-lab-lch). | ||
<details> | ||
<summary><b><code>toXyz()</code></b> (<b>xyz</b> plugin)</summary> | ||
<summary><b><code>.toXyz()</code></b> (<b>xyz</b> plugin)</summary> | ||
@@ -313,3 +360,3 @@ Converts a color to [CIE XYZ](https://www.sttmedia.com/colormodel-xyz) color space. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code). | ||
<details> | ||
<summary><b><code>alpha(value)</code></b></summary> | ||
<summary><b><code>.alpha(value)</code></b></summary> | ||
@@ -325,3 +372,3 @@ Changes the alpha channel value and returns a new `Colord` instance. | ||
<details> | ||
<summary><b><code>invert()</code></b></summary> | ||
<summary><b><code>.invert()</code></b></summary> | ||
@@ -338,3 +385,3 @@ Creates a new `Colord` instance containing an inverted (opposite) version of the color. | ||
<details> | ||
<summary><b><code>saturate(amount = 0.1)</code></b></summary> | ||
<summary><b><code>.saturate(amount = 0.1)</code></b></summary> | ||
@@ -351,3 +398,3 @@ Increases the [HSL saturation](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. | ||
<details> | ||
<summary><b><code>desaturate(amount = 0.1)</code></b></summary> | ||
<summary><b><code>.desaturate(amount = 0.1)</code></b></summary> | ||
@@ -364,3 +411,3 @@ Decreases the [HSL saturation](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. | ||
<details> | ||
<summary><b><code>grayscale()</code></b></summary> | ||
<summary><b><code>.grayscale()</code></b></summary> | ||
@@ -377,3 +424,3 @@ Makes a gray color with the same lightness as a source color. Same as calling `desaturate(1)`. | ||
<details> | ||
<summary><b><code>lighten(amount = 0.1)</code></b></summary> | ||
<summary><b><code>.lighten(amount = 0.1)</code></b></summary> | ||
@@ -391,3 +438,3 @@ Increases the [HSL lightness](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. | ||
<details> | ||
<summary><b><code>darken(amount = 0.1)</code></b></summary> | ||
<summary><b><code>.darken(amount = 0.1)</code></b></summary> | ||
@@ -405,3 +452,3 @@ Decreases the [HSL lightness](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. | ||
<details> | ||
<summary><b><code>mix(color2, ratio = 0.5)</code></b> (<b>mix</b> plugin)</summary> | ||
<summary><b><code>.mix(color2, ratio = 0.5)</code></b> (<b>mix</b> plugin)</summary> | ||
@@ -431,3 +478,3 @@ Produces a mixture of two colors and returns the result of mixing them (new Colord instance). | ||
<details> | ||
<summary><b><code>isValid()</code></b></summary> | ||
<summary><b><code>.isValid()</code></b></summary> | ||
@@ -448,3 +495,3 @@ Returns a boolean indicating whether or not an input has been parsed successfully. | ||
<details> | ||
<summary><b><code>alpha()</code></b></summary> | ||
<summary><b><code>.alpha()</code></b></summary> | ||
@@ -459,3 +506,3 @@ ```js | ||
<details> | ||
<summary><b><code>brightness()</code></b></summary> | ||
<summary><b><code>.brightness()</code></b></summary> | ||
@@ -473,3 +520,3 @@ Returns the brightness of a color (from 0 to 1). The calculation logic is modified from [Web Content Accessibility Guidelines](https://www.w3.org/TR/AERT/#color-contrast). | ||
<details> | ||
<summary><b><code>isLight()</code></b></summary> | ||
<summary><b><code>.isLight()</code></b></summary> | ||
@@ -487,3 +534,3 @@ Same as calling `brightness() >= 0.5`. | ||
<details> | ||
<summary><b><code>isDark()</code></b></summary> | ||
<summary><b><code>.isDark()</code></b></summary> | ||
@@ -501,3 +548,3 @@ Same as calling `brightness() < 0.5`. | ||
<details> | ||
<summary><b><code>luminance()</code></b> (<b>a11y</b> plugin)</summary> | ||
<summary><b><code>.luminance()</code></b> (<b>a11y</b> plugin)</summary> | ||
@@ -516,3 +563,3 @@ Returns the relative luminance of a color, normalized to 0 for darkest black and 1 for lightest white as defined by [WCAG 2.0](https://www.w3.org/TR/WCAG20/#relativeluminancedef). | ||
<details> | ||
<summary><b><code>contrast(color2 = "#FFF")</code></b> (<b>a11y</b> plugin)</summary> | ||
<summary><b><code>.contrast(color2 = "#FFF")</code></b> (<b>a11y</b> plugin)</summary> | ||
@@ -532,3 +579,3 @@ Calculates a contrast ratio for a color pair. This luminance difference is expressed as a ratio ranging from 1 (e.g. white on white) to 21 (e.g., black on a white). [WCAG Accessibility Level AA requires](https://webaim.org/articles/contrast/) a ratio of at least 4.5 for normal text and 3 for large text. | ||
<details> | ||
<summary><b><code>isReadable(color2 = "#FFF", options?)</code></b> (<b>a11y</b> plugin)</summary> | ||
<summary><b><code>.isReadable(color2 = "#FFF", options?)</code></b> (<b>a11y</b> plugin)</summary> | ||
@@ -600,3 +647,3 @@ Checks that a background and text color pair is readable according to [WCAG 2.0 Contrast and Color Requirements](https://webaim.org/articles/contrast/). | ||
<details> | ||
<summary><b><code>hwb</code> (HWB color model)</b> <i>0.5 KB</i></summary> | ||
<summary><b><code>hwb</code> (HWB color model)</b> <i>0.8 KB</i></summary> | ||
@@ -611,7 +658,7 @@ Adds support of [Hue-Whiteness-Blackness](https://en.wikipedia.org/wiki/HWB_color_model) color model. | ||
colord("#ffffff").toHwb(); // { h: 0, w: 100, b: 0, a: 1 } | ||
colord("#555aaa").toHwb(); // { h: 236, w: 33, b: 33, a: 1 } | ||
colord("#999966").toHwb(); // { h: 60, w: 40, b: 40, a: 1 } | ||
colord("#003366").toHwbString(); // "hwb(210, 0%, 60%)" | ||
colord({ h: 0, w: 0, b: 100 }).toHex(); // "#000000" | ||
colord({ h: 0, w: 100, b: 0, a: 1 }).toHex(); // "#ffffff" | ||
colord({ h: 60, w: 40, b: 40 }).toHex(); // "#999966" | ||
colord("hwb(210 0% 60% / 50%)").toHex(); // "#00336680" | ||
``` | ||
@@ -618,0 +665,0 @@ |
@@ -51,4 +51,7 @@ export declare type RgbColor = { | ||
export declare type InputObject = Record<string, unknown>; | ||
export declare type Format = "name" | "hex" | "rgb" | "hsl" | "hsv" | "hwb" | "xyz" | "lab" | "lch"; | ||
export declare type Input = string | InputObject; | ||
export declare type Parser<I extends Input> = (input: I) => RgbaColor | null; | ||
export declare type ParseResult = [RgbaColor, Format]; | ||
export declare type ParseFunction<I extends Input> = (input: I) => RgbaColor | null; | ||
export declare type Parser<I extends Input> = [ParseFunction<I>, Format]; | ||
export declare type Parsers = { | ||
@@ -55,0 +58,0 @@ string: Array<Parser<string>>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
85525
495
767