8889841cPK?[ types.d.tsnuW+Aexport declare type RgbColor = { r: number; g: number; b: number; }; export declare type HslColor = { h: number; s: number; l: number; }; export declare type HsvColor = { h: number; s: number; v: number; }; export declare type HwbColor = { h: number; w: number; b: number; }; export interface XyzColor { x: number; y: number; z: number; } export interface LabColor { l: number; a: number; b: number; } export interface LchColor { l: number; c: number; h: number; } export interface CmykColor { c: number; m: number; y: number; k: number; } declare type WithAlpha = O & { a: number; }; export declare type RgbaColor = WithAlpha; export declare type HslaColor = WithAlpha; export declare type HsvaColor = WithAlpha; export declare type HwbaColor = WithAlpha; export declare type XyzaColor = WithAlpha; export declare type LabaColor = LabColor & { alpha: number; }; export declare type LchaColor = WithAlpha; export declare type CmykaColor = WithAlpha; export declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor; export declare type AnyColor = string | ObjectColor; export declare type InputObject = Record; export declare type Format = "name" | "hex" | "rgb" | "hsl" | "hsv" | "hwb" | "xyz" | "lab" | "lch" | "cmyk"; export declare type Input = string | InputObject; export declare type ParseResult = [RgbaColor, Format]; export declare type ParseFunction = (input: I) => RgbaColor | null; export declare type Parser = [ParseFunction, Format]; export declare type Parsers = { string: Array>; object: Array>; }; export {}; PK?["T((index.jsnuW+AObject.defineProperty(exports,"__esModule",{value:!0});var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},o=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},a=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},s=/^#([0-9a-f]{3,8})$/i,i=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=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),s=a?o===t?(n-e)/a:o===n?2+(e-t)/a:4+(t-n)/a:0;return{h:60*(s<0?s+6:s),s:o?a/o*100:0,v:o/255*100,a:u}},b=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),s=e*(1-(t-o)*n),i=e*(1-(1-t+o)*n),h=o%6;return{r:255*[e,s,a,a,i,e][h],g:255*[i,e,e,s,a,a][h],b:255*[a,a,i,e,e,s][h],a:u}},d=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},g=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((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=h(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*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,c=/^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*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=s.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?n(parseInt(r[3]+r[3],16)/255,2):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?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null: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(t){var n=l.exec(t)||c.exec(t);if(!n)return null;var e,u,o=d({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(o)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,a=r.a,s=void 0===a?1:a;return t(n)&&t(e)&&t(u)?o({r:Number(n),g:Number(e),b:Number(u),a:Number(s)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,o=r.a,a=void 0===o?1:o;if(!t(n)||!t(e)||!t(u))return null;var s=d({h:Number(n),s:Number(e),l:Number(u),a:Number(a)});return f(s)},"hsl"],[function(r){var n=r.h,o=r.s,a=r.v,s=r.a,i=void 0===s?1:s;if(!t(n)||!t(o)||!t(a))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(o),v:Number(a),a:Number(i)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n=.5},r.prototype.toHex=function(){return r=a(this.rgba),t=r.r,e=r.g,u=r.b,s=(o=r.a)<1?i(n(255*o)):"","#"+i(t)+i(e)+i(u)+s;var r,t,e,u,o,s},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 g(p(this.rgba))},r.prototype.toHslString=function(){return r=g(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=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};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(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),j(M(this.rgba,-r))},r.prototype.grayscale=function(){return j(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),j(H(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),j(H(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?j({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=p(this.rgba);return"number"==typeof r?j({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===j(r).toHex()},r}(),j=function(r){return r instanceof $?r:new $(r)},w=[];exports.Colord=$,exports.colord=j,exports.extend=function(r){r.forEach(function(r){w.indexOf(r)<0&&(r($,y),w.push(r))})},exports.getFormat=function(r){return x(r)[1]},exports.random=function(){return new $({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; PK?[p= index.mjsnuW+Avar r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=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}},b=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),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((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},c=function(r){return{h:(t=h(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*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,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*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={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?n(parseInt(r[3]+r[3],16)/255,2):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?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null: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},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,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 d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(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=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({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),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};export{j as Colord,w as colord,k as extend,I as getFormat,E as random}; PK?[ɲK README.mdnuW+A
Colord is a tiny yet powerful tool for high-performance color manipulations and conversions.
## Features - 📦 **Small**: Just **1.7 KB** gzipped ([3x+ lighter](#benchmarks) than **color** and **tinycolor2**) - 🚀 **Fast**: [3x+ faster](#benchmarks) than **color** and **tinycolor2** - 😍 **Simple**: Chainable API and familiar patterns - 💪 **Immutable**: No need to worry about data mutations - 🛡 **Bulletproof**: Written in strict TypeScript and has 100% test coverage - 🗂 **Typed**: Ships with [types included](#types) - 🏗 **Extendable**: Built-in [plugin system](#plugins) to add new functionality - 📚 **CSS-compliant**: Strictly follows CSS Color Level specifications - 👫 **Works everywhere**: Supports all browsers and Node.js - 💨 **Dependency-free**
---
## Benchmarks | Library | Operations/sec | Size
(minified) | Size
(gzipped) | Dependencies | Type declarations | | ----------------------------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | | colord 👑 | 3,524,989 | [![](https://badgen.net/bundlephobia/min/colord?color=6ead0a&label=)](https://bundlephobia.com/result?p=colord) | [![](https://badgen.net/bundlephobia/minzip/colord?color=6ead0a&label=)](https://bundlephobia.com/result?p=colord) | [![](https://badgen.net/bundlephobia/dependency-count/colord?color=6ead0a&label=)](https://bundlephobia.com/result?p=colord) | [![](https://badgen.net/npm/types/colord?color=6ead0a&label=)](https://bundlephobia.com/result?p=colord) | | color | 744,263 | [![](https://badgen.net/bundlephobia/min/color?color=red&label=)](https://bundlephobia.com/result?p=color) | [![](https://badgen.net/bundlephobia/minzip/color?color=red&label=)](https://bundlephobia.com/result?p=color) | [![](https://badgen.net/bundlephobia/dependency-count/color?color=red&label=)](https://bundlephobia.com/result?p=color) | [![](https://badgen.net/npm/types/color?color=e6591d&label=)](https://bundlephobia.com/result?p=color) | | tinycolor2 | 971,312 | [![](https://badgen.net/bundlephobia/min/tinycolor2?color=red&label=)](https://bundlephobia.com/result?p=tinycolor2) | [![](https://badgen.net/bundlephobia/minzip/tinycolor2?color=red&label=)](https://bundlephobia.com/result?p=tinycolor2) | [![](https://badgen.net/bundlephobia/dependency-count/tinycolor2?color=6ead0a&label=)](https://bundlephobia.com/result?p=tinycolor2) | [![](https://badgen.net/npm/types/tinycolor2?color=e6591d&label=)](https://bundlephobia.com/result?p=tinycolor2) | | ac-colors | 660,722 | [![](https://badgen.net/bundlephobia/min/ac-colors?color=e6591d&label=)](https://bundlephobia.com/result?p=ac-colors) | [![](https://badgen.net/bundlephobia/minzip/ac-colors?color=e6591d&label=)](https://bundlephobia.com/result?p=ac-colors) | [![](https://badgen.net/bundlephobia/dependency-count/ac-colors?color=6ead0a&label=)](https://bundlephobia.com/result?p=ac-colors) | [![](https://badgen.net/npm/types/ac-colors?color=red&label=)](https://bundlephobia.com/result?p=ac-colors) | | chroma-js | 962,967 | [![](https://badgen.net/bundlephobia/min/chroma-js?color=red&label=)](https://bundlephobia.com/result?p=chroma-js) | [![](https://badgen.net/bundlephobia/minzip/chroma-js?color=red&label=)](https://bundlephobia.com/result?p=chroma-js) | [![](https://badgen.net/bundlephobia/dependency-count/chroma-js?color=red&label=)](https://bundlephobia.com/result?p=chroma-js) | [![](https://badgen.net/npm/types/chroma-js?color=e6591d&label=)](https://bundlephobia.com/result?p=chroma-js) | The performance results were generated on a MBP 2019, 2,6 GHz Intel Core i7 by running `npm run benchmark` in the library folder. See [tests/benchmark.ts](https://github.com/omgovich/colord/blob/master/tests/benchmark.ts).
---
## Getting Started ``` npm i colord ``` ```js import { colord } from "colord"; colord("#ff0000").grayscale().alpha(0.25).toRgbString(); // "rgba(128, 128, 128, 0.25)" colord("rgb(192, 192, 192)").isLight(); // true colord("hsl(0, 50%, 50%)").darken(0.25).toHex(); // "#602020" ```
---
## Supported Color Models - Hexadecimal strings (including 3, 4 and 8 digit notations) - RGB strings and objects - HSL strings and objects - HSV objects - Color names ([via plugin](#plugins)) - HWB objects and strings ([via plugin](#plugins)) - CMYK objects and strings ([via plugin](#plugins)) - LCH objects and strings ([via plugin](#plugins)) - LAB objects ([via plugin](#plugins)) - XYZ objects ([via plugin](#plugins))
---
## API ### Color parsing
colord(input) Parses the given input and creates a new Colord instance. String parsing strictly conforms to [CSS Color Level Specifications](https://www.w3.org/TR/css-color-4/#color-type). ```js import { colord } from "colord"; // String input examples colord("#FFF"); colord("#ffffff"); colord("#ffffffff"); colord("rgb(255, 255, 255)"); colord("rgba(255, 255, 255, 0.5)"); colord("rgba(100% 100% 100% / 50%)"); colord("hsl(90, 100%, 100%)"); colord("hsla(90, 100%, 100%, 0.5)"); colord("hsla(90deg 100% 100% / 50%)"); colord("tomato"); // requires "names" plugin // Object input examples colord({ r: 255, g: 255, b: 255 }); colord({ r: 255, g: 255, b: 255, a: 1 }); colord({ h: 360, s: 100, l: 100 }); colord({ h: 360, s: 100, l: 100, a: 1 }); colord({ h: 360, s: 100, v: 100 }); colord({ h: 360, s: 100, v: 100, a: 1 }); ``` Check out the ["Plugins"](#plugins) section for more input format examples.
getFormat(input) 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 ```
### Color conversion
.toHex() 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`. ```js colord("rgb(0, 255, 0)").toHex(); // "#00ff00" colord({ h: 300, s: 100, l: 50 }).toHex(); // "#ff00ff" colord({ r: 255, g: 255, b: 255, a: 0 }).toHex(); // "#ffffff00" ```
.toRgb() ```js colord("#ff0000").toRgb(); // { r: 255, g: 0, b: 0, a: 1 } colord({ h: 180, s: 100, l: 50, a: 0.5 }).toRgb(); // { r: 0, g: 255, b: 255, a: 0.5 } ```
.toRgbString() ```js colord("#ff0000").toRgbString(); // "rgb(255, 0, 0)" colord({ h: 180, s: 100, l: 50, a: 0.5 }).toRgbString(); // "rgba(0, 255, 255, 0.5)" ```
.toHsl() Converts a color to [HSL color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and returns an object. ```js colord("#ffff00").toHsl(); // { h: 60, s: 100, l: 50, a: 1 } colord("rgba(0, 0, 255, 0.5) ").toHsl(); // { h: 240, s: 100, l: 50, a: 0.5 } ```
.toHslString() 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). ```js colord("#ffff00").toHslString(); // "hsl(60, 100%, 50%)" colord("rgba(0, 0, 255, 0.5)").toHslString(); // "hsla(240, 100%, 50%, 0.5)" ```
.toHsv() Converts a color to [HSV color space](https://en.wikipedia.org/wiki/HSL_and_HSV) and returns an object. ```js colord("#ffff00").toHsv(); // { h: 60, s: 100, v: 100, a: 1 } colord("rgba(0, 255, 255, 0.5) ").toHsv(); // { h: 180, s: 100, v: 100, a: 1 } ```
.toName(options?) (names plugin) 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. ```js import { colord, extend } from "colord"; import namesPlugin from "colord/plugins/names"; extend([namesPlugin]); colord("#ff6347").toName(); // "tomato" colord("#00ffff").toName(); // "cyan" colord("rgba(0, 0, 0, 0)").toName(); // "transparent" colord("#fe0000").toName(); // undefined (the color is not specified in CSS specs) colord("#fe0000").toName({ closest: true }); // "red" (closest color available) ```
.toCmyk() (cmyk plugin) Converts a color to [CMYK](https://en.wikipedia.org/wiki/CMYK_color_model) color space. ```js import { colord, extend } from "colord"; import cmykPlugin from "colord/plugins/cmyk"; extend([cmykPlugin]); colord("#ffffff").toCmyk(); // { c: 0, m: 0, y: 0, k: 0, a: 1 } colord("#555aaa").toCmyk(); // { c: 50, m: 47, y: 0, k: 33, a: 1 } ```
.toCmykString() (cmyk plugin) Converts a color to color space. Converts a color to [CMYK](https://en.wikipedia.org/wiki/CMYK_color_model) color space and expresses it through the [functional notation](https://www.w3.org/TR/css-color-4/#device-cmyk) ```js import { colord, extend } from "colord"; import cmykPlugin from "colord/plugins/cmyk"; extend([cmykPlugin]); colord("#99ffff").toCmykString(); // "device-cmyk(40% 0% 0% 0%)" colord("#00336680").toCmykString(); // "device-cmyk(100% 50% 0% 60% / 0.5)" ```
.toHwb() (hwb plugin) Converts a color to [HWB (Hue-Whiteness-Blackness)](https://en.wikipedia.org/wiki/HWB_color_model) color space. ```js import { colord, extend } from "colord"; import hwbPlugin from "colord/plugins/hwb"; extend([hwbPlugin]); colord("#ffffff").toHwb(); // { h: 0, w: 100, b: 0, a: 1 } colord("#555aaa").toHwb(); // { h: 236, w: 33, b: 33, a: 1 } ```
.toHwbString() (hwb plugin) 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)" ```
.toLab() (lab plugin) 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). ```js import { colord, extend } from "colord"; import labPlugin from "colord/plugins/lab"; extend([labPlugin]); colord("#ffffff").toLab(); // { l: 100, a: 0, b: 0, alpha: 1 } colord("#33221180").toLab(); // { l: 14.89, a: 5.77, b: 14.41, alpha: 0.5 } ```
.toLch() (lch plugin) 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). ```js import { colord, extend } from "colord"; import lchPlugin from "colord/plugins/lch"; extend([lchPlugin]); colord("#ffffff").toLch(); // { l: 100, c: 0, h: 0, a: 1 } colord("#213b0b").toLch(); // { l: 21.85, c: 31.95, h: 127.77, a: 1 } ```
.toLchString() (lch plugin) 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). ```js import { colord, extend } from "colord"; import lchPlugin from "colord/plugins/lch"; extend([lchPlugin]); colord("#ffffff").toLchString(); // "lch(100% 0 0)" colord("#213b0b").alpha(0.5).toLchString(); // "lch(21.85% 31.95 127.77 / 0.5)" ```
.toXyz() (xyz plugin) 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). ```js import { colord, extend } from "colord"; import xyzPlugin from "colord/plugins/xyz"; extend([xyzPlugin]); colord("#ffffff").toXyz(); // { x: 95.047, y: 100, z: 108.883, a: 1 } ```
### Color manipulation
.alpha(value) Changes the alpha channel value and returns a new `Colord` instance. ```js colord("rgb(0, 0, 0)").alpha(0.5).toRgbString(); // "rgba(0, 0, 0, 0.5)" ```
.invert() Creates a new `Colord` instance containing an inverted (opposite) version of the color. ```js colord("#ffffff").invert().toHex(); // "#000000" colord("#aabbcc").invert().toHex(); // "#554433" ```
.saturate(amount = 0.1) Increases the [HSL saturation](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. ```js colord("#bf4040").saturate(0.25).toHex(); // "#df2020" colord("hsl(0, 50%, 50%)").saturate(0.5).toHslString(); // "hsl(0, 100%, 50%)" ```
.desaturate(amount = 0.1) Decreases the [HSL saturation](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. ```js colord("#df2020").saturate(0.25).toHex(); // "#bf4040" colord("hsl(0, 100%, 50%)").saturate(0.5).toHslString(); // "hsl(0, 50%, 50%)" ```
.grayscale() Makes a gray color with the same lightness as a source color. Same as calling `desaturate(1)`. ```js colord("#bf4040").grayscale().toHex(); // "#808080" colord("hsl(0, 100%, 50%)").grayscale().toHslString(); // "hsl(0, 0%, 50%)" ```
.lighten(amount = 0.1) Increases the [HSL lightness](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. ```js colord("#000000").lighten(0.5).toHex(); // "#808080" colord("#223344").lighten(0.3).toHex(); // "#5580aa" colord("hsl(0, 50%, 50%)").lighten(0.5).toHslString(); // "hsl(0, 50%, 100%)" ```
.darken(amount = 0.1) Decreases the [HSL lightness](https://en.wikipedia.org/wiki/HSL_and_HSV) of a color by the given amount. ```js colord("#ffffff").darken(0.5).toHex(); // "#808080" colord("#5580aa").darken(0.3).toHex(); // "#223344" colord("hsl(0, 50%, 100%)").lighten(0.5).toHslString(); // "hsl(0, 50%, 50%)" ```
.hue(value) Changes the hue value and returns a new `Colord` instance. ```js colord("hsl(90, 50%, 50%)").hue(180).toHslString(); // "hsl(180, 50%, 50%)" colord("hsl(90, 50%, 50%)").hue(370).toHslString(); // "hsl(10, 50%, 50%)" ```
.rotate(amount = 15) Increases the [HSL](https://en.wikipedia.org/wiki/HSL_and_HSV) hue value of a color by the given amount. ```js colord("hsl(90, 50%, 50%)").rotate(90).toHslString(); // "hsl(180, 50%, 50%)" colord("hsl(90, 50%, 50%)").rotate(-180).toHslString(); // "hsl(270, 50%, 50%)" ```
.mix(color2, ratio = 0.5) (mix plugin) Produces a mixture of two colors and returns the result of mixing them (new Colord instance). In contrast to other libraries that perform RGB values mixing, Colord mixes colors through [LAB color space](https://en.wikipedia.org/wiki/CIELAB_color_space). This approach produces better results and doesn't have the drawbacks the legacy way has. → [Online demo](https://3cg7o.csb.app/) ```js import { colord, extend } from "colord"; import mixPlugin from "colord/plugins/mix"; extend([mixPlugin]); colord("#ffffff").mix("#000000").toHex(); // "#777777" colord("#800080").mix("#dda0dd").toHex(); // "#af5cae" colord("#cd853f").mix("#eee8aa", 0.6).toHex(); // "#e3c07e" colord("#008080").mix("#808000", 0.35).toHex(); // "#50805d" ```
.tints(count = 5) (mix plugin) Provides functionality to generate [tints](https://en.wikipedia.org/wiki/Tints_and_shades) of a color. Returns an array of `Colord` instances, including the original color. ```js import { colord, extend } from "colord"; import mixPlugin from "colord/plugins/mix"; extend([mixPlugin]); const color = colord("#ff0000"); color.tints(3).map((c) => c.toHex()); // ["#ff0000", "#ff9f80", "#ffffff"]; ```
.shades(count = 5) (mix plugin) Provides functionality to generate [shades](https://en.wikipedia.org/wiki/Tints_and_shades) of a color. Returns an array of `Colord` instances, including the original color. ```js import { colord, extend } from "colord"; import mixPlugin from "colord/plugins/mix"; extend([mixPlugin]); const color = colord("#ff0000"); color.shades(3).map((c) => c.toHex()); // ["#ff0000", "#7a1b0b", "#000000"]; ```
.tones(count = 5) (mix plugin) Provides functionality to generate [tones](https://en.wikipedia.org/wiki/Tints_and_shades) of a color. Returns an array of `Colord` instances, including the original color. ```js import { colord, extend } from "colord"; import mixPlugin from "colord/plugins/mix"; extend([mixPlugin]); const color = colord("#ff0000"); color.tones(3).map((c) => c.toHex()); // ["#ff0000", "#c86147", "#808080"]; ```
.harmonies(type = "complementary") (harmonies plugin) Provides functionality to generate [harmony colors](). Returns an array of `Colord` instances. ```js import { colord, extend } from "colord"; import harmoniesPlugin from "colord/plugins/harmonies"; extend([harmoniesPlugin]); const color = colord("#ff0000"); color.harmonies("analogous").map((c) => c.toHex()); // ["#ff0080", "#ff0000", "#ff8000"] color.harmonies("complementary").map((c) => c.toHex()); // ["#ff0000", "#00ffff"] color.harmonies("double-split-complementary").map((c) => c.toHex()); // ["#ff0080", "#ff0000", "#ff8000", "#00ff80", "#0080ff"] color.harmonies("rectangle").map((c) => c.toHex()); // ["#ff0000", "#ffff00", "#00ffff", "#0000ff"] color.harmonies("split-complementary").map((c) => c.toHex()); // ["#ff0000", "#00ff80", "#0080ff"] color.harmonies("tetradic").map((c) => c.toHex()); // ["#ff0000", "#80ff00", "#00ffff", "#8000ff"] color.harmonies("triadic").map((c) => c.toHex()); // ["#ff0000", "#00ff00", "#0000ff"] ```
### Color analysis
.isValid() Returns a boolean indicating whether or not an input has been parsed successfully. Note: If parsing is unsuccessful, Colord defaults to black (does not throws an error). ```js colord("#ffffff").isValid(); // true colord("#wwuutt").isValid(); // false colord("abracadabra").isValid(); // false colord({ r: 0, g: 0, b: 0 }).isValid(); // true colord({ r: 0, g: 0, v: 0 }).isValid(); // false ```
.isEqual(color2) Determines whether two values are the same color. ```js colord("#000000").isEqual("rgb(0, 0, 0)"); // true colord("#000000").isEqual("rgb(255, 255, 255)"); // false ```
.alpha() ```js colord("#ffffff").alpha(); // 1 colord("rgba(50, 100, 150, 0.5)").alpha(); // 0.5 ```
.hue() ```js colord("hsl(90, 50%, 50%)").hue(); // 90 colord("hsl(-10, 50%, 50%)").hue(); // 350 ```
.brightness() 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). ```js colord("#000000").brightness(); // 0 colord("#808080").brightness(); // 0.5 colord("#ffffff").brightness(); // 1 ```
.isLight() Same as calling `brightness() >= 0.5`. ```js colord("#111111").isLight(); // false colord("#aabbcc").isLight(); // true colord("#ffffff").isLight(); // true ```
.isDark() Same as calling `brightness() < 0.5`. ```js colord("#111111").isDark(); // true colord("#aabbcc").isDark(); // false colord("#ffffff").isDark(); // false ```
.luminance() (a11y plugin) 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). ```js colord("#000000").luminance(); // 0 colord("#808080").luminance(); // 0.22 colord("#ccddee").luminance(); // 0.71 colord("#ffffff").luminance(); // 1 ```
.contrast(color2 = "#FFF") (a11y plugin) 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. ```js colord("#000000").contrast(); // 21 (black on white) colord("#ffffff").contrast("#000000"); // 21 (white on black) colord("#777777").contrast(); // 4.47 (gray on white) colord("#ff0000").contrast(); // 3.99 (red on white) colord("#0000ff").contrast("#ff000"); // 2.14 (blue on red) ```
.isReadable(color2 = "#FFF", options?) (a11y plugin) Checks that a background and text color pair is readable according to [WCAG 2.0 Contrast and Color Requirements](https://webaim.org/articles/contrast/). ```js colord("#000000").isReadable(); // true (normal black text on white bg conforms to WCAG AA) colord("#777777").isReadable(); // false (normal gray text on white bg conforms to WCAG AA) colord("#ffffff").isReadable("#000000"); // true (normal white text on black bg conforms to WCAG AA) colord("#e60000").isReadable("#ffff47"); // true (normal red text on yellow bg conforms to WCAG AA) colord("#e60000").isReadable("#ffff47", { level: "AAA" }); // false (normal red text on yellow bg does not conform to WCAG AAA) colord("#e60000").isReadable("#ffff47", { level: "AAA", size: "large" }); // true (large red text on yellow bg conforms to WCAG AAA) ```
.delta(color2 = "#FFF") (lab plugin) Calculates the perceived color difference between two colors. The difference calculated according to [Delta E2000](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000). The return value is `0` if the colors are equal, `1` if they are entirely different. ```js colord("#3296fa").delta("#197dc8"); // 0.099 colord("#faf0c8").delta("#ffffff"); // 0.148 colord("#afafaf").delta("#b4b4b4"); // 0.014 colord("#000000").delta("#ffffff"); // 1 ```
### Color utilities
random() Returns a new Colord instance with a random color value inside. ```js import { random } from "colord"; random().toHex(); // "#01c8ec" random().alpha(0.5).toRgb(); // { r: 13, g: 237, b: 162, a: 0.5 } ```
.minify(options?) Converts a color to its shortest string representation. ```js import { colord, extend } from "colord"; import minifyPlugin from "colord/plugins/minify"; extend([minifyPlugin]); colord("black").minify(); // "#000" colord("#112233").minify(); // "#123" colord("darkgray").minify(); // "#a9a9a9" colord("rgba(170,170,170,0.4)").minify(); // "hsla(0,0%,67%,.4)" colord("rgba(170,170,170,0.4)").minify({ alphaHex: true }); // "#aaa6" ``` | Option | Default | Description | | ------------- | ------- | ------------------------------------------------------------ | | `hex` | `true` | Enable `#rrggbb` and `#rgb` notations | | `alphaHex` | `false` | Enable `#rrggbbaa` and `#rgba` notations | | `rgb` | `true` | Enable `rgb()` and `rgba()` functional notations | | `hsl` | `true` | Enable `hsl()` and `hsla()` functional notations | | `name` | `false` | Enable CSS color keywords. Requires `names` plugin installed | | `transparent` | `false` | Enable `"transparent"` color keyword |
---
## Plugins **Colord** has a built-in plugin system that allows new features and functionality to be easily added.
a11y (Accessibility) 0.38 KB Adds accessibility and color contrast utilities working according to [Web Content Accessibility Guidelines 2.0](https://www.w3.org/TR/WCAG20/). ```js import { colord, extend } from "colord"; import a11yPlugin from "colord/plugins/a11y"; extend([a11yPlugin]); colord("#000000").luminance(); // 0 colord("#ccddee").luminance(); // 0.71 colord("#ffffff").luminance(); // 1 colord("#000000").contrast(); // 21 (black on white) colord("#ffffff").contrast("#000000"); // 21 (white on black) colord("#0000ff").contrast("#ff000"); // 2.14 (blue on red) colord("#000000").isReadable(); // true (black on white) colord("#ffffff").isReadable("#000000"); // true (white on black) colord("#777777").isReadable(); // false (gray on white) colord("#e60000").isReadable("#ffff47"); // true (normal red text on yellow bg conforms to WCAG AA) colord("#e60000").isReadable("#ffff47", { level: "AAA" }); // false (normal red text on yellow bg does not conform to WCAG AAA) colord("#e60000").isReadable("#ffff47", { level: "AAA", size: "large" }); // true (large red text on yellow bg conforms to WCAG AAA) ```
cmyk (CMYK color space) 0.6 KB Adds support of [CMYK](https://www.sttmedia.com/colormodel-cmyk) color model. ```js import { colord, extend } from "colord"; import cmykPlugin from "colord/plugins/cmyk"; extend([cmykPlugin]); colord("#ffffff").toCmyk(); // { c: 0, m: 0, y: 0, k: 0, a: 1 } colord("#999966").toCmykString(); // "device-cmyk(0% 0% 33% 40%)" colord({ c: 0, m: 0, y: 0, k: 100, a: 1 }).toHex(); // "#000000" colord("device-cmyk(0% 61% 72% 0% / 50%)").toHex(); // "#ff634780" ```
harmonies (Color harmonies) 0.15 KB Provides functionality to generate [harmony colors](). ```js import { colord, extend } from "colord"; import harmonies from "colord/plugins/harmonies"; extend([harmonies]); const color = colord("#ff0000"); color.harmonies("analogous").map((c) => c.toHex()); // ["#ff0080", "#ff0000", "#ff8000"] color.harmonies("complementary").map((c) => c.toHex()); // ["#ff0000", "#00ffff"] color.harmonies("double-split-complementary").map((c) => c.toHex()); // ["#ff0080", "#ff0000", "#ff8000", "#00ff80", "#0080ff"] color.harmonies("rectangle").map((c) => c.toHex()); // ["#ff0000", "#ffff00", "#00ffff", "#0000ff"] color.harmonies("split-complementary").map((c) => c.toHex()); // ["#ff0000", "#00ff80", "#0080ff"] color.harmonies("tetradic").map((c) => c.toHex()); // ["#ff0000", "#80ff00", "#00ffff", "#8000ff"] color.harmonies("triadic").map((c) => c.toHex()); // ["#ff0000", "#00ff00", "#0000ff"] ```
hwb (HWB color model) 0.8 KB Adds support of [Hue-Whiteness-Blackness](https://en.wikipedia.org/wiki/HWB_color_model) color model. ```js import { colord, extend } from "colord"; import hwbPlugin from "colord/plugins/hwb"; extend([hwbPlugin]); colord("#999966").toHwb(); // { h: 60, w: 40, b: 40, a: 1 } colord("#003366").toHwbString(); // "hwb(210 0% 60%)" colord({ h: 60, w: 40, b: 40 }).toHex(); // "#999966" colord("hwb(210 0% 60% / 50%)").toHex(); // "#00336680" ```
lab (CIE LAB color space) 1.4 KB Adds support of [CIE LAB](https://en.wikipedia.org/wiki/CIELAB_color_space) color model. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code). Also plugin provides `.delta` method for [perceived color difference calculations](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000). ```js import { colord, extend } from "colord"; import labPlugin from "colord/plugins/lab"; extend([labPlugin]); colord({ l: 53.24, a: 80.09, b: 67.2 }).toHex(); // "#ff0000" colord("#ffffff").toLab(); // { l: 100, a: 0, b: 0, alpha: 1 } colord("#afafaf").delta("#b4b4b4"); // 0.014 colord("#000000").delta("#ffffff"); // 1 ```
lch (CIE LCH color space) 1.3 KB Adds support of [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). ```js import { colord, extend } from "colord"; import lchPlugin from "colord/plugins/lch"; extend([lchPlugin]); colord({ l: 100, c: 0, h: 0 }).toHex(); // "#ffffff" colord("lch(48.25% 30.07 196.38)").toHex(); // "#008080" colord("#646464").toLch(); // { l: 42.37, c: 0, h: 0, a: 1 } colord("#646464").alpha(0.5).toLchString(); // "lch(42.37% 0 0 / 0.5)" ```
minify (Color string minification) 0.5 KB A plugin adding color string minification utilities. ```js import { colord, extend } from "colord"; import minifyPlugin from "colord/plugins/minify"; extend([minifyPlugin]); colord("black").minify(); // "#000" colord("#112233").minify(); // "#123" colord("darkgray").minify(); // "#a9a9a9" colord("rgba(170,170,170,0.4)").minify(); // "hsla(0,0%,67%,.4)" colord("rgba(170,170,170,0.4)").minify({ alphaHex: true }); // "#aaa6" ```
mix (Color mixing) 0.96 KB A plugin adding color mixing utilities. In contrast to other libraries that perform RGB values mixing, Colord mixes colors through [LAB color space](https://en.wikipedia.org/wiki/CIELAB_color_space). This approach produces better results and doesn't have the drawbacks the legacy way has. → [Online demo](https://3cg7o.csb.app/) ```js import { colord, extend } from "colord"; import mixPlugin from "colord/plugins/mix"; extend([mixPlugin]); colord("#ffffff").mix("#000000").toHex(); // "#777777" colord("#800080").mix("#dda0dd").toHex(); // "#af5cae" colord("#cd853f").mix("#eee8aa", 0.6).toHex(); // "#e3c07e" colord("#008080").mix("#808000", 0.35).toHex(); // "#50805d" ``` Also, the plugin provides special mixtures such as [tints, shades, and tones](https://en.wikipedia.org/wiki/Tints_and_shades):
tints, shades, and tones mixtures
```js const color = colord("#ff0000"); color.tints(3).map((c) => c.toHex()); // ["#ff0000", "#ff9f80", "#ffffff"]; color.shades(3).map((c) => c.toHex()); // ["#ff0000", "#7a1b0b", "#000000"]; color.tones(3).map((c) => c.toHex()); // ["#ff0000", "#c86147", "#808080"]; ```
names (CSS color keywords) 1.45 KB Provides options to convert a color into a [CSS color keyword](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#color_keywords) and vice versa. ```js import { colord, extend } from "colord"; import namesPlugin from "colord/plugins/names"; extend([namesPlugin]); colord("tomato").toHex(); // "#ff6347" colord("#00ffff").toName(); // "cyan" colord("rgba(0, 0, 0, 0)").toName(); // "transparent" colord("#fe0000").toName(); // undefined (the color is not specified in CSS specs) colord("#fe0000").toName({ closest: true }); // "red" (closest color) ```
xyz (CIE XYZ color space) 0.7 KB Adds support of [CIE XYZ](https://www.sttmedia.com/colormodel-xyz) color model. The conversion logic is ported from [CSS Color Module Level 4 Specification](https://www.w3.org/TR/css-color-4/#color-conversion-code). ```js import { colord, extend } from "colord"; import xyzPlugin from "colord/plugins/xyz"; extend([xyzPlugin]); colord("#ffffff").toXyz(); // { x: 95.047, y: 100, z: 108.883, a: 1 } colord({ x: 0, y: 0, z: 0 }).toHex(); // "#000000" ```
---
## Types **Colord** is written in strict TypeScript and ships with types in the library itself — no need for any other install. We provide everything you need in one tiny package. While not only typing its own functions and variables, **Colord** can also help you type yours. Depending on the color space you are using, you can also import and use the type that is associated with it. ```ts import { RgbColor, RgbaColor, HslColor, HslaColor, HsvColor, HsvaColor } from "colord"; const foo: HslColor = { h: 0, s: 0, l: 0 }; const bar: RgbColor = { r: 0, g: 0, v: 0 }; // ERROR ```
---
## Projects using Colord - [cssnano](https://github.com/cssnano/cssnano) — the most popular CSS minification tool - [Resume.io](https://resume.io/) — online resume builder with over 12,000,000 users worldwide - [Leva](https://github.com/pmndrs/leva) — open source extensible GUI panel made for React - [Qui Max](https://github.com/Qvant-lab/qui-max) — Vue.js design system and component library - and [thousands more](https://github.com/omgovich/colord/network/dependents)...
---
## Roadmap - [x] Parse and convert Hex, RGB(A), HSL(A), HSV(A) - [x] Saturate, desaturate, grayscale - [x] Trim an input value - [x] Clamp input numbers to resolve edge cases (e.g. `rgb(256, -1, 999, 2)`) - [x] `brightness`, `isDark`, `isLight` - [x] Set and get `alpha` - [x] Plugin API - [x] 4 and 8 digit Hex - [x] `lighten`, `darken` - [x] `invert` - [x] CSS color names (via plugin) - [x] A11y and contrast utils (via plugin) - [x] XYZ color space (via plugin) - [x] [HWB](https://drafts.csswg.org/css-color/#the-hwb-notation) color space (via plugin) - [x] [LAB](https://www.w3.org/TR/css-color-4/#resolving-lab-lch-values) color space (via plugin) - [x] [LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space (via plugin) - [x] Mix colors (via plugin) - [x] CMYK color space (via plugin) PK?[x9^;; LICENSE.mdnuW+AMIT License Copyright (c) 2020 Vlad Shilov omgovich@ya.ru Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK?[3ppconstants.d.tsnuW+A/** * We used to work with 2 digits after the decimal point, but it wasn't accurate enough, * so the library produced colors that were perceived differently. */ export declare const ALPHA_PRECISION = 3; /** * Valid CSS units. * https://developer.mozilla.org/en-US/docs/Web/CSS/angle */ export declare const ANGLE_UNITS: Record; PK?[]1uPP random.d.tsnuW+Aimport { Colord } from "./colord"; export declare const random: () => Colord; PK?[B?u  colord.d.tsnuW+Aimport { AnyColor, RgbaColor, HslaColor, HsvaColor } from "./types"; export declare class Colord { private readonly parsed; readonly rgba: RgbaColor; constructor(input: AnyColor); /** * Returns a boolean indicating whether or not an input has been parsed successfully. * Note: If parsing is unsuccessful, Colord defaults to black (does not throws an error). */ isValid(): boolean; /** * Returns the brightness of a color (from 0 to 1). * The calculation logic is modified from WCAG. * https://www.w3.org/TR/AERT/#color-contrast */ brightness(): number; /** * Same as calling `brightness() < 0.5`. */ isDark(): boolean; /** * Same as calling `brightness() >= 0.5`. * */ isLight(): boolean; /** * Returns the hexadecimal representation of a color. * When the alpha channel value of the color is less than 1, * it outputs #rrggbbaa format instead of #rrggbb. */ toHex(): string; /** * Converts a color to RGB color space and returns an object. * Always includes an alpha value from 0 to 1. */ toRgb(): RgbaColor; /** * Converts a color to RGB color space and returns a string representation. * Outputs an alpha value only if it is less than 1. */ toRgbString(): string; /** * Converts a color to HSL color space and returns an object. * Always includes an alpha value from 0 to 1. */ toHsl(): HslaColor; /** * Converts a color to HSL color space and returns a string representation. * Always includes an alpha value from 0 to 1. */ toHslString(): string; /** * Converts a color to HSV color space and returns an object. * Always includes an alpha value from 0 to 1. */ toHsv(): HsvaColor; /** * Creates a new instance containing an inverted (opposite) version of the color. */ invert(): Colord; /** * Increases the HSL saturation of a color by the given amount. */ saturate(amount?: number): Colord; /** * Decreases the HSL saturation of a color by the given amount. */ desaturate(amount?: number): Colord; /** * Makes a gray color with the same lightness as a source color. */ grayscale(): Colord; /** * Increases the HSL lightness of a color by the given amount. */ lighten(amount?: number): Colord; /** * Increases the HSL lightness of a color by the given amount. */ darken(amount?: number): Colord; /** * Changes the HSL hue of a color by the given amount. */ rotate(amount?: number): Colord; /** * Allows to get or change an alpha channel value. */ alpha(): number; alpha(value: number): Colord; /** * Allows to get or change a hue value. */ hue(): number; hue(value: number): Colord; /** * Determines whether two values are the same color. */ isEqual(color: AnyColor | Colord): boolean; } /** * Parses the given input color and creates a new `Colord` instance. * See accepted input formats: https://github.com/omgovich/colord#color-parsing */ export declare const colord: (input: AnyColor | Colord) => Colord; PK?[ g helpers.d.tsnuW+Aexport declare const isPresent: (value: unknown) => boolean; export declare const round: (number: number, digits?: number, base?: number) => number; export declare const floor: (number: number, digits?: number, base?: number) => number; /** * Clamps a value between an upper and lower bound. * We use ternary operators because it makes the minified code * is 2 times shorter then `Math.min(Math.max(a,b),c)` * NaN is clamped to the lower bound */ export declare const clamp: (number: number, min?: number, max?: number) => number; /** * Processes and clamps a degree (angle) value properly. * Any `NaN` or `Infinity` will be converted to `0`. * Examples: -1 => 359, 361 => 1 */ export declare const clampHue: (degrees: number) => number; /** * Converts a hue value to degrees from 0 to 360 inclusive. */ export declare const parseHue: (value: string, unit?: string) => number; PK?[B CHANGELOG.mdnuW+A### 2.9.3 - Fix types export for TypeScript 4.7 ❤️ [@pkishorez](https://github.com/pkishorez) ### 2.9.2 - Fix: Add "package.json" to exports map ### 2.9.1 - Fix: Make minification lossless - Fix: Minify to name only if color is opaque ### 2.9.0 - New plugin: Color string minification 🗜 ### 2.8.0 - New `delta` method to calculate the perceived color difference between two colors ❤️ [@EricRovell](https://github.com/EricRovell) ### 2.7.0 - Improve `mix` plugin by adding new `tints`, `tones` and `shades` methods ❤️ [@EricRovell](https://github.com/EricRovell) ### 2.6.0 - Support "double split complementary" color harmony generation ❤️ [@EricRovell](https://github.com/EricRovell) & [@lbragile](https://github.com/lbragile) ### 2.5.0 - New `closest` option of `toName` method allows you to find the closest color if there is no exact match ### 2.4.0 - New plugin: Color harmonies generator ❤️ [@EricRovell](https://github.com/EricRovell) ### 2.3.0 - Add new `isEqual` method ❤️ [@EricRovell](https://github.com/EricRovell) ### 2.2.0 - New plugin: CMYK color space ❤️ [@EricRovell](https://github.com/EricRovell) ### 2.1.0 - Add new `hue` and `rotate` methods ### 2.0.1 - Improve the precision of alpha values ### 2.0.0 - Strict string color parsing conforming to the CSS Color Level specifications ### 1.7.2 - Simplify package "exports" field to improve different environments support ### 1.7.1 - Parse a color name disregarding the case ### 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`) ### 1.5.0 - New utility: Random color generation ### 1.4.1 - Mix colors through CIE LAB color space ### 1.4.0 - New plugin: Color mixing - Adjust XYZ, LAB and LCH conversions to the D50 white point ([according to the latest CSS specs](https://drafts.csswg.org/css-color-5/#color-spaces)). ### 1.3.1 - Support modern CSS notations of RGB, HSL and LCH color functions ### 1.3.0 - New plugin: CIE LCH color space ### 1.2.1 - Fix: Do not treat 7-digit hex as a valid color ❤️ [@subzey](https://github.com/subzey) - Parser update: Turn NaN input values into valid numbers ❤️ [@subzey](https://github.com/subzey) ### 1.2.0 - New plugin: CIE LAB color space ### 1.1.1 - Make bundle 1% lighter ### 1.1.0 - Add `isValid` method ### 1.0 - An official production-ready release ### 0.10.2 - Sort named colors dictionary for better compression ❤️ [@subzey](https://github.com/subzey) ### 0.10.1 - Ignore `null` input in the parsers ### 0.10 - Shorten conversion method names (`toRgba` to `toRgb`, etc) ### 0.9.3 - New plugin: HWB color model - More accurate HSL and HSV conversions ### 0.9.2 - Names plugin: Support "transparent" keyword ### 0.9.1 - Improve package exports ### 0.9 - Add CommonJS exports ### 0.8 - New plugin: a11y (Accessibility) ### 0.7 - New plugin: CIE XYZ color space ### 0.6.2 - 20% speed improvement ❤️ [@jeetiss](https://github.com/jeetiss) ### 0.6.1 - 100% code coverage ### 0.6 - Make plugin available in Parcel which doesn't support exports map yet - Fix names plugin TS declarations export - Documentation ### 0.5 - New plugin: CSS color names ### 0.4 - Make the library ESM-first - Add code coverage reports ### 0.3 - Implement Plugin API ### 0.2 - Support 4 and 8 digit Hex ### 0.1 - Basic API PK?[ȬI extend.d.tsnuW+Aimport { Colord } from "./colord"; import { Parsers } from "./types"; export declare type Plugin = (ColordClass: typeof Colord, parsers: Parsers) => void; export declare const extend: (plugins: Plugin[]) => void; PK?[զ{[[ index.d.tsnuW+Aexport { 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"; PK?[Kp parse.d.tsnuW+Aimport { 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) => ParseResult | [null, undefined]; /** * Returns a color model name for the input passed to the function. */ export declare const getFormat: (input: Input) => Format | undefined; PK?[ U U plugins/lab.jsnuW+Avar a=function(a){return"string"==typeof a?a.length>0:"number"==typeof a},t=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=Math.pow(10,t)),Math.round(o*a)/o+0},o=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=1),a>o?o:a>t?a:t},r=function(a){var t=a/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},h=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},n=96.422,p=100,M=82.521,u=function(a){var t,r,n={x:.9555766*(t=a).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 r={r:h(.032404542*n.x-.015371385*n.y-.004985314*n.z),g:h(-.00969266*n.x+.018760108*n.y+41556e-8*n.z),b:h(556434e-9*n.x-.002040259*n.y+.010572252*n.z),a:a.a},{r:o(r.r,0,255),g:o(r.g,0,255),b:o(r.b,0,255),a:o(r.a)}},e=function(a){var t=r(a.r),h=r(a.g),u=r(a.b);return function(a){return{x:o(a.x,0,n),y:o(a.y,0,p),z:o(a.z,0,M),a:o(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*t+.3575761*h+.1804375*u),y:100*(.2126729*t+.7151522*h+.072175*u),z:100*(.0193339*t+.119192*h+.9503041*u),a:a.a}))},w=216/24389,b=24389/27,i=function(t){var r=t.l,h=t.a,n=t.b,p=t.alpha,M=void 0===p?1:p;if(!a(r)||!a(h)||!a(n))return null;var u=function(a){return{l:o(a.l,0,400),a:a.a,b:a.b,alpha:o(a.alpha)}}({l:Number(r),a:Number(h),b:Number(n),alpha:Number(M)});return l(u)},l=function(a){var t=(a.l+16)/116,o=a.a/500+t,r=t-a.b/200;return u({x:(Math.pow(o,3)>w?Math.pow(o,3):(116*o-16)/b)*n,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/b)*p,z:(Math.pow(r,3)>w?Math.pow(r,3):(116*r-16)/b)*M,a:a.alpha})};module.exports=function(a,r){a.prototype.toLab=function(){return o=e(this.rgba),h=o.y/p,u=o.z/M,r=(r=o.x/n)>w?Math.cbrt(r):(b*r+16)/116,a={l:116*(h=h>w?Math.cbrt(h):(b*h+16)/116)-16,a:500*(r-h),b:200*(h-(u=u>w?Math.cbrt(u):(b*u+16)/116)),alpha:o.a},{l:t(a.l,2),a:t(a.a,2),b:t(a.b,2),alpha:t(a.alpha,3)};var a,o,r,h,u},a.prototype.delta=function(r){void 0===r&&(r="#FFF");var h=r instanceof a?r:new a(r),n=function(a,t){var o=a.l,r=a.a,h=a.b,n=t.l,p=t.a,M=t.b,u=180/Math.PI,e=Math.PI/180,w=Math.pow(Math.pow(r,2)+Math.pow(h,2),.5),b=Math.pow(Math.pow(p,2)+Math.pow(M,2),.5),i=(o+n)/2,l=Math.pow((w+b)/2,7),c=.5*(1-Math.pow(l/(l+Math.pow(25,7)),.5)),f=r*(1+c),y=p*(1+c),v=Math.pow(Math.pow(f,2)+Math.pow(h,2),.5),x=Math.pow(Math.pow(y,2)+Math.pow(M,2),.5),z=(v+x)/2,s=0===f&&0===h?0:Math.atan2(h,f)*u,d=0===y&&0===M?0:Math.atan2(M,y)*u;s<0&&(s+=360),d<0&&(d+=360);var g=d-s,m=Math.abs(d-s);m>180&&d<=s?g+=360:m>180&&d>s&&(g-=360);var N=s+d;m<=180?N/=2:N=(s+d<360?N+360:N-360)/2;var F=1-.17*Math.cos(e*(N-30))+.24*Math.cos(2*e*N)+.32*Math.cos(e*(3*N+6))-.2*Math.cos(e*(4*N-63)),L=n-o,I=x-v,P=2*Math.sin(e*g/2)*Math.pow(v*x,.5),j=1+.015*Math.pow(i-50,2)/Math.pow(20+Math.pow(i-50,2),.5),k=1+.045*z,q=1+.015*z*F,A=30*Math.exp(-1*Math.pow((N-275)/25,2)),B=-2*Math.pow(l/(l+Math.pow(25,7)),.5)*Math.sin(2*e*A);return Math.pow(Math.pow(L/1/j,2)+Math.pow(I/1/k,2)+Math.pow(P/1/q,2)+B*I*P/(1*k*1*q),.5)}(this.toLab(),h.toLab())/100;return o(t(n,3))},r.object.push([i,"lab"])}; PK?[M5plugins/xyz.jsnuW+Avar 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,3)}}((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"])}; PK?[TOplugins/minify.d.tsnuW+Aimport { Plugin } from "../extend"; interface MinificationOptions { hex?: boolean; alphaHex?: boolean; rgb?: boolean; hsl?: boolean; name?: boolean; transparent?: boolean; } declare module "../colord" { interface Colord { /** Returns the shortest string representation of the color */ minify(options?: MinificationOptions): string; } } /** * A plugin adding a color minification utilities. */ declare const minifyPlugin: Plugin; export default minifyPlugin; PK?[ __plugins/cmyk.jsnuW+Avar 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){return{c:t(r.c,0,100),m:t(r.m,0,100),y:t(r.y,0,100),k:t(r.k,0,100),a:t(r.a)}},e=function(r){return{c:n(r.c,2),m:n(r.m,2),y:n(r.y,2),k:n(r.k,2),a:n(r.a,3)}};function c(r){return{r:n(255*(1-r.c/100)*(1-r.k/100)),g:n(255*(1-r.m/100)*(1-r.k/100)),b:n(255*(1-r.y/100)*(1-r.k/100)),a:r.a}}function o(r){var t=1-Math.max(r.r/255,r.g/255,r.b/255),u=(1-r.r/255-t)/(1-t),e=(1-r.g/255-t)/(1-t),c=(1-r.b/255-t)/(1-t);return{c:isNaN(u)?0:n(100*u),m:isNaN(e)?0:n(100*e),y:isNaN(c)?0:n(100*c),k:n(100*t),a:r.a}}function i(n){var t=n.c,e=n.m,o=n.y,i=n.k,m=n.a,a=void 0===m?1:m;return r(t)&&r(e)&&r(o)&&r(i)?c(u({c:Number(t),m:Number(e),y:Number(o),k:Number(i),a:Number(a)})):null}var m=/^device-cmyk\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,a=function(r){var n=m.exec(r);return n?c(u({c:Number(n[1])*(n[2]?1:100),m:Number(n[3])*(n[4]?1:100),y:Number(n[5])*(n[6]?1:100),k:Number(n[7])*(n[8]?1:100),a:void 0===n[9]?1:Number(n[9])/(n[10]?100:1)})):null};module.exports=function(r,n){r.prototype.toCmyk=function(){return e(o(this.rgba))},r.prototype.toCmykString=function(){return r=e(o(this.rgba)),n=r.c,t=r.m,u=r.y,c=r.k,(i=r.a)<1?"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"% / "+i+")":"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"%)";var r,n,t,u,c,i},n.object.push([i,"cmyk"]),n.string.push([a,"cmyk"])}; PK?[W11plugins/mix.jsnuW+Avar t=function(t,a,n){return void 0===a&&(a=0),void 0===n&&(n=1),t>n?n:t>a?t:a},a=function(t){var a=t/255;return a<.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)},n=function(t){return 255*(t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t)},r=96.422,o=100,u=82.521,e=function(a){var r,o,u={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 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:a.a},{r:t(o.r,0,255),g:t(o.g,0,255),b:t(o.b,0,255),a:t(o.a)}},i=function(n){var e=a(n.r),i=a(n.g),p=a(n.b);return function(a){return{x:t(a.x,0,r),y:t(a.y,0,o),z:t(a.z,0,u),a:t(a.a)}}(function(t){return{x:1.0478112*t.x+.0228866*t.y+-.050127*t.z,y:.0295424*t.x+.9904844*t.y+-.0170491*t.z,z:-.0092345*t.x+.0150436*t.y+.7521316*t.z,a:t.a}}({x:100*(.4124564*e+.3575761*i+.1804375*p),y:100*(.2126729*e+.7151522*i+.072175*p),z:100*(.0193339*e+.119192*i+.9503041*p),a:n.a}))},p=216/24389,h=24389/27,f=function(t){var a=i(t),n=a.x/r,e=a.y/o,f=a.z/u;return n=n>p?Math.cbrt(n):(h*n+16)/116,{l:116*(e=e>p?Math.cbrt(e):(h*e+16)/116)-16,a:500*(n-e),b:200*(e-(f=f>p?Math.cbrt(f):(h*f+16)/116)),alpha:a.a}},c=function(a,n,i){var c,y=f(a),x=f(n);return function(t){var a=(t.l+16)/116,n=t.a/500+a,i=a-t.b/200;return e({x:(Math.pow(n,3)>p?Math.pow(n,3):(116*n-16)/h)*r,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/h)*o,z:(Math.pow(i,3)>p?Math.pow(i,3):(116*i-16)/h)*u,a:t.alpha})}({l:t((c={l:y.l*(1-i)+x.l*i,a:y.a*(1-i)+x.a*i,b:y.b*(1-i)+x.b*i,alpha:y.alpha*(1-i)+x.alpha*i}).l,0,400),a:c.a,b:c.b,alpha:t(c.alpha)})};module.exports=function(t){function a(t,a,n){void 0===n&&(n=5);for(var r=[],o=1/(n-1),u=0;u<=n-1;u++)r.push(t.mix(a,o*u));return r}t.prototype.mix=function(a,n){void 0===n&&(n=.5);var r=a instanceof t?a:new t(a),o=c(this.toRgb(),r.toRgb(),n);return new t(o)},t.prototype.tints=function(t){return a(this,"#fff",t)},t.prototype.shades=function(t){return a(this,"#000",t)},t.prototype.tones=function(t){return a(this,"#808080",t)}}; PK?[ZZplugins/harmonies.d.tsnuW+Aimport { Plugin } from "../extend"; export declare type HarmonyType = "analogous" | "complementary" | "double-split-complementary" | "rectangle" | "split-complementary" | "tetradic" | "triadic"; declare module "../colord" { interface Colord { /** * Returns an array of harmony colors as `Colord` instances. */ harmonies(type?: HarmonyType): Colord[]; } } /** * A plugin adding functionality to generate harmony colors. * https://en.wikipedia.org/wiki/Harmony_(color) */ declare const harmoniesPlugin: Plugin; export default harmoniesPlugin; PK?[5plugins/xyz.mjsnuW+Avar 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)}};export default 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,3)}}((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"])} PK?[= plugins/names.mjsnuW+Aexport default 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"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u0:"number"==typeof r},a=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=Math.pow(10,t)),Math.round(a*r)/a+0},n=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=1),r>a?a:r>t?r:t},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,a,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 a={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:n(a.r,0,255),g:n(a.g,0,255),b:n(a.b,0,255),a:n(a.a)}},l=function(r){var t=u(r.r),a=u(r.g),h=u(r.b);return function(r){return{x:n(r.x,0,o),y:n(r.y,0,e),z:n(r.z,0,c),a:n(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*a+.1804375*h),y:100*(.2126729*t+.7151522*a+.072175*h),z:100*(.0193339*t+.119192*a+.9503041*h),a:r.a}))},f=216/24389,b=24389/27,d=function(r){return{l:n(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:a(r.l,2),c:a(r.c,2),h:a(r.h,2),a:a(r.a,3)}},v=function(r){var a=r.l,n=r.c,u=r.h,h=r.a,o=void 0===h?1:h;if(!t(a)||!t(n)||!t(u))return null;var e=d({l:Number(a),c:Number(n),h:Number(u),a:Number(o)});return M(e)},y=function(r){var t=function(r){var t=l(r),a=t.x/o,n=t.y/e,u=t.z/c;return a=a>f?Math.cbrt(a):(b*a+16)/116,{l:116*(n=n>f?Math.cbrt(n):(b*n+16)/116)-16,a:500*(a-n),b:200*(n-(u=u>f?Math.cbrt(u):(b*u+16)/116)),alpha:t.a}}(r),n=a(t.a,3),u=a(t.b,3),h=Math.atan2(u,n)/Math.PI*180;return{l:t.l,c:Math.sqrt(n*n+u*u),h:h<0?h+360:h,a:t.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)>f?Math.pow(n,3):(116*n-16)/b)*o,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/b)*e,z:(Math.pow(u,3)>f?Math.pow(u,3):(116*u-16)/b)*c,a:t.alpha});var t,a,n,u},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(t){var a=x.exec(t);if(!a)return null;var n,u,h=d({l:Number(a[1]),c:Number(a[2]),h:(n=a[3],u=a[4],void 0===u&&(u="deg"),Number(n)*(r[u]||1)),a:void 0===a[5]?1:Number(a[5])/(a[6]?100:1)});return M(h)};export default 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"])} PK?[XURRplugins/mix.d.tsnuW+Aimport { AnyColor } from "../types"; import { Plugin } from "../extend"; declare module "../colord" { interface Colord { /** * Produces a mixture of two colors through CIE LAB color space and returns a new Colord instance. */ mix(color2: AnyColor | Colord, ratio?: number): Colord; /** * Generates a tints palette based on original color. */ tints(count?: number): Colord[]; /** * Generates a shades palette based on original color. */ shades(count?: number): Colord[]; /** * Generates a tones palette based on original color. */ tones(count?: number): Colord[]; } } /** * A plugin adding a color mixing utilities. */ declare const mixPlugin: Plugin; export default mixPlugin; PK?[TRRplugins/a11y.d.tsnuW+Aimport { AnyColor } from "../types"; import { Plugin } from "../extend"; interface ReadabilityOptions { level?: "AA" | "AAA"; size?: "normal" | "large"; } declare module "../colord" { interface Colord { /** * Returns the relative luminance of a color, * normalized to 0 for darkest black and 1 for lightest white. * https://www.w3.org/TR/WCAG20/#relativeluminancedef * https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance */ luminance(): number; /** * 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 requires a ratio of at least 4.5 for normal text and 3 for large text. * https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html * https://webaim.org/articles/contrast/ */ contrast(color2?: AnyColor | Colord): number; /** * Checks that a background and text color pair conforms to WCAG 2.0 requirements. * https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html */ isReadable(color2?: AnyColor | Colord, options?: ReadabilityOptions): boolean; } } /** * A plugin adding accessibility and color contrast utilities. * Follows Web Content Accessibility Guidelines 2.0. * https://www.w3.org/TR/WCAG20/ */ declare const a11yPlugin: Plugin; export default a11yPlugin; PK?[{.;T T plugins/lab.mjsnuW+Avar a=function(a){return"string"==typeof a?a.length>0:"number"==typeof a},t=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=Math.pow(10,t)),Math.round(o*a)/o+0},o=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=1),a>o?o:a>t?a:t},r=function(a){var t=a/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},h=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},n=96.422,p=100,M=82.521,u=function(a){var t,r,n={x:.9555766*(t=a).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 r={r:h(.032404542*n.x-.015371385*n.y-.004985314*n.z),g:h(-.00969266*n.x+.018760108*n.y+41556e-8*n.z),b:h(556434e-9*n.x-.002040259*n.y+.010572252*n.z),a:a.a},{r:o(r.r,0,255),g:o(r.g,0,255),b:o(r.b,0,255),a:o(r.a)}},e=function(a){var t=r(a.r),h=r(a.g),u=r(a.b);return function(a){return{x:o(a.x,0,n),y:o(a.y,0,p),z:o(a.z,0,M),a:o(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*t+.3575761*h+.1804375*u),y:100*(.2126729*t+.7151522*h+.072175*u),z:100*(.0193339*t+.119192*h+.9503041*u),a:a.a}))},w=216/24389,b=24389/27,i=function(t){var r=t.l,h=t.a,n=t.b,p=t.alpha,M=void 0===p?1:p;if(!a(r)||!a(h)||!a(n))return null;var u=function(a){return{l:o(a.l,0,400),a:a.a,b:a.b,alpha:o(a.alpha)}}({l:Number(r),a:Number(h),b:Number(n),alpha:Number(M)});return l(u)},l=function(a){var t=(a.l+16)/116,o=a.a/500+t,r=t-a.b/200;return u({x:(Math.pow(o,3)>w?Math.pow(o,3):(116*o-16)/b)*n,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/b)*p,z:(Math.pow(r,3)>w?Math.pow(r,3):(116*r-16)/b)*M,a:a.alpha})};export default function(a,r){a.prototype.toLab=function(){return o=e(this.rgba),h=o.y/p,u=o.z/M,r=(r=o.x/n)>w?Math.cbrt(r):(b*r+16)/116,a={l:116*(h=h>w?Math.cbrt(h):(b*h+16)/116)-16,a:500*(r-h),b:200*(h-(u=u>w?Math.cbrt(u):(b*u+16)/116)),alpha:o.a},{l:t(a.l,2),a:t(a.a,2),b:t(a.b,2),alpha:t(a.alpha,3)};var a,o,r,h,u},a.prototype.delta=function(r){void 0===r&&(r="#FFF");var h=r instanceof a?r:new a(r),n=function(a,t){var o=a.l,r=a.a,h=a.b,n=t.l,p=t.a,M=t.b,u=180/Math.PI,e=Math.PI/180,w=Math.pow(Math.pow(r,2)+Math.pow(h,2),.5),b=Math.pow(Math.pow(p,2)+Math.pow(M,2),.5),i=(o+n)/2,l=Math.pow((w+b)/2,7),c=.5*(1-Math.pow(l/(l+Math.pow(25,7)),.5)),f=r*(1+c),y=p*(1+c),v=Math.pow(Math.pow(f,2)+Math.pow(h,2),.5),x=Math.pow(Math.pow(y,2)+Math.pow(M,2),.5),z=(v+x)/2,s=0===f&&0===h?0:Math.atan2(h,f)*u,d=0===y&&0===M?0:Math.atan2(M,y)*u;s<0&&(s+=360),d<0&&(d+=360);var g=d-s,m=Math.abs(d-s);m>180&&d<=s?g+=360:m>180&&d>s&&(g-=360);var N=s+d;m<=180?N/=2:N=(s+d<360?N+360:N-360)/2;var F=1-.17*Math.cos(e*(N-30))+.24*Math.cos(2*e*N)+.32*Math.cos(e*(3*N+6))-.2*Math.cos(e*(4*N-63)),L=n-o,I=x-v,P=2*Math.sin(e*g/2)*Math.pow(v*x,.5),j=1+.015*Math.pow(i-50,2)/Math.pow(20+Math.pow(i-50,2),.5),k=1+.045*z,q=1+.015*z*F,A=30*Math.exp(-1*Math.pow((N-275)/25,2)),B=-2*Math.pow(l/(l+Math.pow(25,7)),.5)*Math.sin(2*e*A);return Math.pow(Math.pow(L/1/j,2)+Math.pow(I/1/k,2)+Math.pow(P/1/q,2)+B*I*P/(1*k*1*q),.5)}(this.toLab(),h.toLab())/100;return o(t(n,3))},r.object.push([i,"lab"])} PK?[|44plugins/hwb.d.tsnuW+Aimport { HwbaColor } from "../types"; import { Plugin } from "../extend"; declare module "../colord" { 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; } } /** * A plugin adding support for HWB (Hue-Whiteness-Blackness) color model. * 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; PK?[<+,,plugins/a11y.mjsnuW+Avar o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},t=function(t){return.2126*o(t.r)+.7152*o(t.g)+.0722*o(t.b)};export default function(o){o.prototype.luminance=function(){return o=t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=t(e),d=t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} PK?[ ~NNplugins/minify.jsnuW+Amodule.exports=function(t){var r=function(t){var r,n,e,i=t.toHex(),a=t.alpha(),h=i.split(""),s=h[1],o=h[2],u=h[3],l=h[4],p=h[5],f=h[6],g=h[7],v=h[8];if(a>0&&a<1&&(r=parseInt(g+v,16)/255,void 0===(n=2)&&(n=0),void 0===e&&(e=Math.pow(10,n)),Math.round(e*r)/e+0!==a))return null;if(s===o&&u===l&&p===f){if(1===a)return"#"+s+u+p;if(g===v)return"#"+s+u+p+g}return i},n=function(t){return t>0&&t<1?t.toString().replace("0.","."):t};t.prototype.minify=function(t){void 0===t&&(t={});var e=this.toRgb(),i=n(e.r),a=n(e.g),h=n(e.b),s=this.toHsl(),o=n(s.h),u=n(s.s),l=n(s.l),p=n(this.alpha()),f=Object.assign({hex:!0,rgb:!0,hsl:!0},t),g=[];if(f.hex&&(1===p||f.alphaHex)){var v=r(this);v&&g.push(v)}if(f.rgb&&g.push(1===p?"rgb("+i+","+a+","+h+")":"rgba("+i+","+a+","+h+","+p+")"),f.hsl&&g.push(1===p?"hsl("+o+","+u+"%,"+l+"%)":"hsla("+o+","+u+"%,"+l+"%,"+p+")"),f.transparent&&0===i&&0===a&&0===h&&0===p)g.push("transparent");else if(1===p&&f.name&&"function"==typeof this.toName){var c=this.toName();c&&g.push(c)}return function(t){for(var r=t[0],n=1;n0&&i<1&&(r=parseInt(g+v,16)/255,void 0===(n=2)&&(n=0),void 0===e&&(e=Math.pow(10,n)),Math.round(e*r)/e+0!==i))return null;if(s===o&&u===l&&p===f){if(1===i)return"#"+s+u+p;if(g===v)return"#"+s+u+p+g}return a},n=function(t){return t>0&&t<1?t.toString().replace("0.","."):t};t.prototype.minify=function(t){void 0===t&&(t={});var e=this.toRgb(),a=n(e.r),i=n(e.g),h=n(e.b),s=this.toHsl(),o=n(s.h),u=n(s.s),l=n(s.l),p=n(this.alpha()),f=Object.assign({hex:!0,rgb:!0,hsl:!0},t),g=[];if(f.hex&&(1===p||f.alphaHex)){var v=r(this);v&&g.push(v)}if(f.rgb&&g.push(1===p?"rgb("+a+","+i+","+h+")":"rgba("+a+","+i+","+h+","+p+")"),f.hsl&&g.push(1===p?"hsl("+o+","+u+"%,"+l+"%)":"hsla("+o+","+u+"%,"+l+"%,"+p+")"),f.transparent&&0===a&&0===i&&0===h&&0===p)g.push("transparent");else if(1===p&&f.name&&"function"==typeof this.toName){var c=this.toName();c&&g.push(c)}return function(t){for(var r=t[0],n=1;n0:"number"==typeof r},a=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=Math.pow(10,t)),Math.round(a*r)/a+0},n=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=1),r>a?a:r>t?r:t},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,a,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 a={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:n(a.r,0,255),g:n(a.g,0,255),b:n(a.b,0,255),a:n(a.a)}},l=function(r){var t=u(r.r),a=u(r.g),h=u(r.b);return function(r){return{x:n(r.x,0,o),y:n(r.y,0,e),z:n(r.z,0,c),a:n(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*a+.1804375*h),y:100*(.2126729*t+.7151522*a+.072175*h),z:100*(.0193339*t+.119192*a+.9503041*h),a:r.a}))},b=216/24389,d=24389/27,f=function(r){return{l:n(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:a(r.l,2),c:a(r.c,2),h:a(r.h,2),a:a(r.a,3)}},v=function(r){var a=r.l,n=r.c,u=r.h,h=r.a,o=void 0===h?1:h;if(!t(a)||!t(n)||!t(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 t=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=a(t.a,3),u=a(t.b,3),h=Math.atan2(u,n)/Math.PI*180;return{l:t.l,c:Math.sqrt(n*n+u*u),h:h<0?h+360:h,a:t.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=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(t){var a=x.exec(t);if(!a)return null;var n,u,h=f({l:Number(a[1]),c:Number(a[2]),h:(n=a[3],u=a[4],void 0===u&&(u="deg"),Number(n)*(r[u]||1)),a:void 0===a[5]?1:Number(a[5])/(a[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"])}; PK?[>$ plugins/names.jsnuW+Amodule.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"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,o=r[this.toHex()];if(o)return o;if(null==f?void 0:f.closest){var n=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=n,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));un?n:t>a?t:a},a=function(t){var a=t/255;return a<.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)},n=function(t){return 255*(t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t)},r=96.422,o=100,u=82.521,e=function(a){var r,o,u={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 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:a.a},{r:t(o.r,0,255),g:t(o.g,0,255),b:t(o.b,0,255),a:t(o.a)}},i=function(n){var e=a(n.r),i=a(n.g),p=a(n.b);return function(a){return{x:t(a.x,0,r),y:t(a.y,0,o),z:t(a.z,0,u),a:t(a.a)}}(function(t){return{x:1.0478112*t.x+.0228866*t.y+-.050127*t.z,y:.0295424*t.x+.9904844*t.y+-.0170491*t.z,z:-.0092345*t.x+.0150436*t.y+.7521316*t.z,a:t.a}}({x:100*(.4124564*e+.3575761*i+.1804375*p),y:100*(.2126729*e+.7151522*i+.072175*p),z:100*(.0193339*e+.119192*i+.9503041*p),a:n.a}))},p=216/24389,h=24389/27,f=function(t){var a=i(t),n=a.x/r,e=a.y/o,f=a.z/u;return n=n>p?Math.cbrt(n):(h*n+16)/116,{l:116*(e=e>p?Math.cbrt(e):(h*e+16)/116)-16,a:500*(n-e),b:200*(e-(f=f>p?Math.cbrt(f):(h*f+16)/116)),alpha:a.a}},c=function(a,n,i){var c,y=f(a),x=f(n);return function(t){var a=(t.l+16)/116,n=t.a/500+a,i=a-t.b/200;return e({x:(Math.pow(n,3)>p?Math.pow(n,3):(116*n-16)/h)*r,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/h)*o,z:(Math.pow(i,3)>p?Math.pow(i,3):(116*i-16)/h)*u,a:t.alpha})}({l:t((c={l:y.l*(1-i)+x.l*i,a:y.a*(1-i)+x.a*i,b:y.b*(1-i)+x.b*i,alpha:y.alpha*(1-i)+x.alpha*i}).l,0,400),a:c.a,b:c.b,alpha:t(c.alpha)})};export default function(t){function a(t,a,n){void 0===n&&(n=5);for(var r=[],o=1/(n-1),u=0;u<=n-1;u++)r.push(t.mix(a,o*u));return r}t.prototype.mix=function(a,n){void 0===n&&(n=.5);var r=a instanceof t?a:new t(a),o=c(this.toRgb(),r.toRgb(),n);return new t(o)},t.prototype.tints=function(t){return a(this,"#fff",t)},t.prototype.shades=function(t){return a(this,"#000",t)},t.prototype.tones=function(t){return a(this,"#808080",t)}} PK?[ |ƃggplugins/cmyk.d.tsnuW+Aimport { CmykaColor } from "../types"; import { Plugin } from "../extend"; declare module "../colord" { interface Colord { /** * Converts a color to CMYK color space and returns an object. * https://drafts.csswg.org/css-color/#cmyk-colors * https://lea.verou.me/2009/03/cmyk-colors-in-css-useful-or-useless/ */ toCmyk(): CmykaColor; /** * Converts a color to CMYK color space and returns a string. * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/device-cmyk() */ toCmykString(): string; } } /** * A plugin adding support for CMYK color space. * https://lea.verou.me/2009/03/cmyk-colors-in-css-useful-or-useless/ * https://en.wikipedia.org/wiki/CMYK_color_model */ declare const cmykPlugin: Plugin; export default cmykPlugin; PK?[/66plugins/hwb.mjsnuW+Avar r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},u=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},a=function(r){return{h:(t=r.h,(t=isFinite(t)?t%360:0)>0?t:t+360),w:u(r.w,0,100),b:u(r.b,0,100),a:u(r.a)};var t},e=function(r){return{h:n(r.h),w:n(r.w),b:n(r.b),a:n(r.a,3)}},b=function(r){return{h:function(r){var t=r.r,n=r.g,u=r.b,a=r.a,e=Math.max(t,n,u),b=e-Math.min(t,n,u),o=b?e===t?(n-u)/b:e===n?2+(u-t)/b:4+(t-n)/b:0;return{h:60*(o<0?o+6:o),s:e?b/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}},o=function(r){return function(r){var t=r.h,n=r.s,u=r.v,a=r.a;t=t/360*6,n/=100,u/=100;var e=Math.floor(t),b=u*(1-n),o=u*(1-(t-e)*n),i=u*(1-(1-t+e)*n),h=e%6;return{r:255*[u,o,b,b,i,u][h],g:255*[i,u,u,o,b,b][h],b:255*[b,b,i,u,u,o][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(r){var n=r.h,u=r.w,e=r.b,b=r.a,i=void 0===b?1:b;if(!t(n)||!t(u)||!t(e))return null;var h=a({h:Number(n),w:Number(u),b:Number(e),a:Number(i)});return o(h)},h=/^hwb\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,d=function(t){var n=h.exec(t);if(!n)return null;var u,e,b=a({h:(u=n[1],e=n[2],void 0===e&&(e="deg"),Number(u)*(r[e]||1)),w:Number(n[3]),b:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return o(b)};export default function(r,t){r.prototype.toHwb=function(){return e(b(this.rgba))},r.prototype.toHwbString=function(){return r=e(b(this.rgba)),t=r.h,n=r.w,u=r.b,(a=r.a)<1?"hwb("+t+" "+n+"% "+u+"% / "+a+")":"hwb("+t+" "+n+"% "+u+"%)";var r,t,n,u,a},t.string.push([d,"hwb"]),t.object.push([i,"hwb"])} PK?[eeplugins/harmonies.mjsnuW+Aexport default function(t){var e={analogous:[-30,0,30],complementary:[0,180],"double-split-complementary":[-30,0,30,150,210],rectangle:[0,60,180,240],tetradic:[0,90,180,270],triadic:[0,120,240],"split-complementary":[0,150,210]};t.prototype.harmonies=function(t){var r=this;return void 0===t&&(t="complementary"),e[t].map(function(t){return r.rotate(t)})}} PK?[Splugins/xyz.d.tsnuW+Aimport { XyzaColor } from "../types"; import { Plugin } from "../extend"; declare module "../colord" { interface Colord { toXyz(): XyzaColor; } } /** * A plugin adding support for CIE XYZ colorspace. * Wikipedia: https://en.wikipedia.org/wiki/CIE_1931_color_space * Helpful article: https://www.sttmedia.com/colormodel-xyz */ declare const xyzPlugin: Plugin; export default xyzPlugin; PK?[y|^^plugins/cmyk.mjsnuW+Avar 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){return{c:t(r.c,0,100),m:t(r.m,0,100),y:t(r.y,0,100),k:t(r.k,0,100),a:t(r.a)}},e=function(r){return{c:n(r.c,2),m:n(r.m,2),y:n(r.y,2),k:n(r.k,2),a:n(r.a,3)}};function c(r){return{r:n(255*(1-r.c/100)*(1-r.k/100)),g:n(255*(1-r.m/100)*(1-r.k/100)),b:n(255*(1-r.y/100)*(1-r.k/100)),a:r.a}}function i(r){var t=1-Math.max(r.r/255,r.g/255,r.b/255),u=(1-r.r/255-t)/(1-t),e=(1-r.g/255-t)/(1-t),c=(1-r.b/255-t)/(1-t);return{c:isNaN(u)?0:n(100*u),m:isNaN(e)?0:n(100*e),y:isNaN(c)?0:n(100*c),k:n(100*t),a:r.a}}function o(n){var t=n.c,e=n.m,i=n.y,o=n.k,m=n.a,a=void 0===m?1:m;return r(t)&&r(e)&&r(i)&&r(o)?c(u({c:Number(t),m:Number(e),y:Number(i),k:Number(o),a:Number(a)})):null}var m=/^device-cmyk\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,a=function(r){var n=m.exec(r);return n?c(u({c:Number(n[1])*(n[2]?1:100),m:Number(n[3])*(n[4]?1:100),y:Number(n[5])*(n[6]?1:100),k:Number(n[7])*(n[8]?1:100),a:void 0===n[9]?1:Number(n[9])/(n[10]?100:1)})):null};export default function(r,n){r.prototype.toCmyk=function(){return e(i(this.rgba))},r.prototype.toCmykString=function(){return r=e(i(this.rgba)),n=r.c,t=r.m,u=r.y,c=r.k,(o=r.a)<1?"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"% / "+o+")":"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"%)";var r,n,t,u,c,o},n.object.push([o,"cmyk"]),n.string.push([a,"cmyk"])} PK?[{wwplugins/names.d.tsnuW+Aimport { Plugin } from "../extend"; interface ConvertOptions { closest?: boolean; } declare module "../colord" { interface Colord { /** Finds CSS color keyword that matches with the color value */ toName(options?: ConvertOptions): string | undefined; } } /** * Plugin to work with named colors. * Adds a parser to read CSS color names and `toName` method. * See https://www.w3.org/TR/css-color-4/#named-colors * Supports 'transparent' string as defined in * https://drafts.csswg.org/css-color/#transparent-color */ declare const namesPlugin: Plugin; export default namesPlugin; PK?[b--plugins/a11y.jsnuW+Avar o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},t=function(t){return.2126*o(t.r)+.7152*o(t.g)+.0722*o(t.b)};module.exports=function(o){o.prototype.luminance=function(){return o=t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,i,a,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=t(e),d=t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(i=2)&&(i=0),void 0===a&&(a=Math.pow(10,i)),Math.floor(a*n)/a+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(a=(r=t).size)?"normal":a,"AAA"===(i=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===i&&"large"===e?3:4.5);var r,n,i,a,e}}; PK?[Էwplugins/lch.d.tsnuW+Aimport { LchaColor } from "../types"; import { Plugin } from "../extend"; declare module "../colord" { interface Colord { /** * Converts a color to CIELCH (Lightness-Chroma-Hue) color space and returns an object. * https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/ * https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model */ toLch(): LchaColor; /** * Converts a color to CIELCH (Lightness-Chroma-Hue) color space and returns a string. * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch() */ toLchString(): string; } } /** * A plugin adding support for CIELCH color space. * https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/ * https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model */ declare const lchPlugin: Plugin; export default lchPlugin; PK?[2Ρffplugins/harmonies.jsnuW+Amodule.exports=function(t){var e={analogous:[-30,0,30],complementary:[0,180],"double-split-complementary":[-30,0,30,150,210],rectangle:[0,60,180,240],tetradic:[0,90,180,270],triadic:[0,120,240],"split-complementary":[0,150,210]};t.prototype.harmonies=function(t){var o=this;return void 0===t&&(t="complementary"),e[t].map(function(t){return o.rotate(t)})}}; PK?[I677plugins/hwb.jsnuW+Avar r={grad:.9,turn:360,rad:360/(2*Math.PI)},n=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},u=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:(n=r.h,(n=isFinite(n)?n%360:0)>0?n:n+360),w:u(r.w,0,100),b:u(r.b,0,100),a:u(r.a)};var n},e=function(r){return{h:t(r.h),w:t(r.w),b:t(r.b),a:t(r.a,3)}},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(r){var t=r.h,u=r.w,e=r.b,o=r.a,i=void 0===o?1:o;if(!n(t)||!n(u)||!n(e))return null;var h=a({h:Number(t),w:Number(u),b:Number(e),a:Number(i)});return b(h)},h=/^hwb\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,d=function(n){var t=h.exec(n);if(!t)return null;var u,e,o=a({h:(u=t[1],e=t[2],void 0===e&&(e="deg"),Number(u)*(r[e]||1)),w:Number(t[3]),b:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[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"])}; PK?[od package.jsonnuW+A{ "name": "colord", "version": "2.9.3", "description": "👑 A tiny yet powerful tool for high-performance color manipulations and conversions", "keywords": [ "color", "parser", "convert", "tiny", "hex", "rgb", "hsl", "hsv", "hwb", "lab", "lch", "xyz", "css", "color-names", "a11y", "cmyk", "mix", "minify", "harmonies" ], "repository": "omgovich/colord", "author": "Vlad Shilov ", "license": "MIT", "sideEffects": false, "main": "./index.js", "module": "./index.mjs", "exports": { ".": { "types": "./index.d.ts", "import": "./index.mjs", "require": "./index.js", "default": "./index.mjs" }, "./plugins/a11y": { "types": "./plugins/a11y.d.ts", "import": "./plugins/a11y.mjs", "require": "./plugins/a11y.js", "default": "./plugins/a11y.mjs" }, "./plugins/cmyk": { "types": "./plugins/cmyk.d.ts", "import": "./plugins/cmyk.mjs", "require": "./plugins/cmyk.js", "default": "./plugins/cmyk.mjs" }, "./plugins/harmonies": { "types": "./plugins/harmonies.d.ts", "import": "./plugins/harmonies.mjs", "require": "./plugins/harmonies.js", "default": "./plugins/harmonies.mjs" }, "./plugins/hwb": { "types": "./plugins/hwb.d.ts", "import": "./plugins/hwb.mjs", "require": "./plugins/hwb.js", "default": "./plugins/hwb.mjs" }, "./plugins/lab": { "types": "./plugins/lab.d.ts", "import": "./plugins/lab.mjs", "require": "./plugins/lab.js", "default": "./plugins/lab.mjs" }, "./plugins/lch": { "types": "./plugins/lch.d.ts", "import": "./plugins/lch.mjs", "require": "./plugins/lch.js", "default": "./plugins/lch.mjs" }, "./plugins/minify": { "types": "./plugins/minify.d.ts", "import": "./plugins/minify.mjs", "require": "./plugins/minify.js", "default": "./plugins/minify.mjs" }, "./plugins/mix": { "types": "./plugins/mix.d.ts", "import": "./plugins/mix.mjs", "require": "./plugins/mix.js", "default": "./plugins/mix.mjs" }, "./plugins/names": { "types": "./plugins/names.d.ts", "import": "./plugins/names.mjs", "require": "./plugins/names.js", "default": "./plugins/names.mjs" }, "./plugins/xyz": { "types": "./plugins/xyz.d.ts", "import": "./plugins/xyz.mjs", "require": "./plugins/xyz.js", "default": "./plugins/xyz.mjs" }, "./package.json": "./package.json" }, "files": [ "*.{js,mjs,ts,map}", "plugins/*.{js,mjs,ts,map}" ], "types": "index.d.ts", "scripts": { "lint": "eslint src/**/*.ts", "size": "npm run build && size-limit", "check-types": "tsc --noEmit true", "test": "jest tests --coverage", "benchmark": "tsc --outDir bench --skipLibCheck --esModuleInterop ./tests/benchmark.ts && node ./bench/tests/benchmark.js && rm -rf ./bench", "build": "rm -rf ./dist/* && rollup --config", "release": "npm run build && cp *.json dist && cp *.md dist && npm publish dist", "check-release": "npm run release -- --dry-run" }, "dependencies": {}, "devDependencies": { "@size-limit/preset-small-lib": "^4.10.1", "@types/jest": "^26.0.22", "@typescript-eslint/eslint-plugin": "^4.19.0", "@typescript-eslint/parser": "^4.19.0", "ac-colors": "^1.4.2", "benny": "^3.6.15", "chroma-js": "^2.1.1", "color": "^3.1.3", "eslint": "^7.14.0", "eslint-config-prettier": "^6.15.0", "eslint-plugin-prettier": "^3.1.4", "glob": "^7.1.6", "jest": "^26.6.3", "prettier": "^2.2.0", "rollup": "^2.43.1", "rollup-plugin-terser": "^7.0.2", "rollup-plugin-typescript2": "^0.30.0", "size-limit": "^4.10.1", "tinycolor2": "^1.4.2", "ts-jest": "^26.5.4", "ts-node": "^9.1.1", "tslib": "^2.1.0", "typescript": "^4.2.3" }, "jest": { "verbose": true, "transform": { "^.+\\.ts$": "ts-jest" } }, "eslintConfig": { "plugins": [ "prettier" ], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended", "prettier/@typescript-eslint" ] }, "prettier": { "printWidth": 100 }, "size-limit": [ { "path": "dist/index.mjs", "import": "{ colord }", "limit": "2 KB" }, { "path": "dist/plugins/a11y.mjs", "limit": "0.5 KB" }, { "path": "dist/plugins/cmyk.mjs", "limit": "1 KB" }, { "path": "dist/plugins/harmonies.mjs", "limit": "0.5 KB" }, { "path": "dist/plugins/hwb.mjs", "limit": "1 KB" }, { "path": "dist/plugins/lab.mjs", "limit": "1.5 KB" }, { "path": "dist/plugins/lch.mjs", "limit": "1.5 KB" }, { "path": "dist/plugins/minify.mjs", "limit": "0.6 KB" }, { "path": "dist/plugins/mix.mjs", "limit": "1 KB" }, { "path": "dist/plugins/names.mjs", "limit": "1.5 KB" }, { "path": "dist/plugins/xyz.mjs", "limit": "1 KB" } ] } PK?[ types.d.tsnuW+APK?["T((#index.jsnuW+APK?[p= index.mjsnuW+APK?[ɲK 6README.mdnuW+APK?[x9^;; LICENSE.mdnuW+APK?[3pp=constants.d.tsnuW+APK?[]1uPP random.d.tsnuW+APK?[B?u  vcolord.d.tsnuW+APK?[ g helpers.d.tsnuW+APK?[B CHANGELOG.mdnuW+APK?[ȬI extend.d.tsnuW+APK?[զ{[[ index.d.tsnuW+APK?[Kp Jparse.d.tsnuW+APK?[ U U 6plugins/lab.jsnuW+APK?[M5plugins/xyz.jsnuW+APK?[TO plugins/minify.d.tsnuW+APK?[ __L plugins/cmyk.jsnuW+APK?[W11plugins/mix.jsnuW+APK?[ZZYplugins/harmonies.d.tsnuW+APK?[5plugins/xyz.mjsnuW+APK?[= )$plugins/names.mjsnuW+APK?[%%:2plugins/lab.d.tsnuW+APK?[=G G 5plugins/lch.mjsnuW+APK?[XURR%Aplugins/mix.d.tsnuW+APK?[TRRDplugins/a11y.d.tsnuW+APK?[{.;T T JKplugins/lab.mjsnuW+APK?[|44Wplugins/hwb.d.tsnuW+APK?[<+,,Q[plugins/a11y.mjsnuW+APK?[ ~NN^plugins/minify.jsnuW+APK?[e΢MMLcplugins/minify.mjsnuW+APK?[i lH H gplugins/lch.jsnuW+APK?[>$ asplugins/names.jsnuW+APK?[:/00rplugins/mix.mjsnuW+APK?[ |ƃggplugins/cmyk.d.tsnuW+APK?[/66plugins/hwb.mjsnuW+APK?[eeplugins/harmonies.mjsnuW+APK?[Splugins/xyz.d.tsnuW+APK?[y|^^plugins/cmyk.mjsnuW+APK?[{ww)plugins/names.d.tsnuW+APK?[b--plugins/a11y.jsnuW+APK?[ԷwNplugins/lch.d.tsnuW+APK?[2Ρff>plugins/harmonies.jsnuW+APK?[I677plugins/hwb.jsnuW+APK?[od ]package.jsonnuW+APK,,~ R