You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

colord

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.3.0

plugins/lch.d.ts

4

CHANGELOG.md

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

### 1.3.0
- New plugin: CIE LCH color space
### 1.2.1

@@ -2,0 +6,0 @@

2

index.d.ts
export { colord, Colord } from "./colord";
export { extend, Plugin } from "./extend";
export { RgbColor, RgbaColor, HslColor, HslaColor, HsvColor, HsvaColor, XyzColor, XyzaColor, HwbColor, HwbaColor, AnyColor, } from "./types";
export { HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, LabColor, LabaColor, LchColor, LchaColor, RgbColor, RgbaColor, XyzColor, XyzaColor, AnyColor, } from "./types";

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

Object.defineProperty(exports,"__esModule",{value:!0});var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},e=function(r){return{r:n(r.r,0,255),g:n(r.g,0,255),b:n(r.b,0,255),a:n(r.a)}},u=function(r){return{r:t(r.r),g:t(r.g),b:t(r.b),a:t(r.a,2)}},o=/^\s*#?([0-9a-f]{3,8})\s*$/i,a=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},i=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,o=Math.max(t,n,e),a=o-Math.min(t,n,e),i=a?o===t?(n-e)/a:o===n?2+(e-t)/a:4+(t-n)/a:0;return{h:60*(i<0?i+6:i),s:o?a/o*100:0,v:o/255*100,a:u}},s=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var o=Math.floor(t),a=e*(1-n),i=e*(1-(t-o)*n),s=e*(1-(1-t+o)*n),b=o%6;return{r:255*[e,i,a,a,s,e][b],g:255*[s,e,e,i,a,a][b],b:255*[a,a,s,e,e,i][b],a:u}},b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),l:n(r.l,0,100),a:n(r.a)}},h=function(r){return{h:t(r.h),s:t(r.s),l:t(r.l),a:t(r.a,2)}},f=function(r){return s((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},g=function(r){return{h:(t=i(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*),?\s*(-?\d+\.?\d*)%?,?\s*(-?\d+\.?\d*)%?,?\s*(-?\d*\.?\d+)?s*\)?/i,p=/rgba?\(?\s*(-?\d+),?\s*(-?\d+),?\s*(-?\d+),?\s*(-?\d*\.?\d+)?\s*\)?/i,c={string:[function(r){var t=o.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?parseInt(r[3]+r[3],16)/255:1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?parseInt(r.substr(6,2),16)/255:1}:null:null},function(r){var t=p.exec(r);return t?e({r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:void 0===t[4]?1:Number(t[4])}):null},function(r){var t=l.exec(r);if(!t)return null;var n=b({h:Number(t[1]),s:Number(t[2]),l:Number(t[3]),a:void 0===t[4]?1:Number(t[4])});return f(n)}],object:[function(t){var n=t.r,u=t.g,o=t.b,a=t.a,i=void 0===a?1:a;return r(n)&&r(u)&&r(o)?e({r:Number(n),g:Number(u),b:Number(o),a:Number(i)}):null},function(t){var n=t.h,e=t.s,u=t.l,o=t.a,a=void 0===o?1:o;if(!r(n)||!r(e)||!r(u))return null;var i=b({h:Number(n),s:Number(e),l:Number(u),a:Number(a)});return f(i)},function(t){var e=t.h,u=t.s,o=t.v,a=t.a,i=void 0===a?1:a;if(!r(e)||!r(u)||!r(o))return null;var b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),v:n(r.v,0,100),a:n(r.a)}}({h:Number(e),s:Number(u),v:Number(o),a:Number(i)});return s(b)}]},v=function(r,t){for(var n=0;n<t.length;n++){var e=t[n](r);if(e)return e}return null},d=function(r,t){var e=g(r);return{h:e.h,s:n(e.s+100*t,0,100),l:e.l,a:e.a}},m=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},y=function(r,t){var e=g(r);return{h:e.h,s:e.s,l:n(e.l+100*t,0,100),a:e.a}},N=function(){function r(r){this.parsed=function(r){return"string"==typeof r?v(r,c.string):"object"==typeof r&&null!==r?v(r,c.object):null}(r),this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return t(m(this.rgba),2)},r.prototype.isDark=function(){return m(this.rgba)<.5},r.prototype.isLight=function(){return m(this.rgba)>=.5},r.prototype.toHex=function(){return r=u(this.rgba),n=r.r,e=r.g,o=r.b,s=(i=r.a)<1?a(t(255*i)):"","#"+a(n)+a(e)+a(o)+s;var r,n,e,o,i,s},r.prototype.toRgb=function(){return u(this.rgba)},r.prototype.toRgbString=function(){return r=u(this.rgba),t=r.r,n=r.g,e=r.b,(o=r.a)<1?"rgba("+t+", "+n+", "+e+", "+o+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,o},r.prototype.toHsl=function(){return h(g(this.rgba))},r.prototype.toHslString=function(){return r=h(g(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=i(this.rgba),{h:t(r.h),s:t(r.s),v:t(r.v),a:t(r.a,2)};var r},r.prototype.invert=function(){return x({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),x(d(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),x(d(this.rgba,-r))},r.prototype.grayscale=function(){return x(d(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),x(y(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),x(y(this.rgba,-r))},r.prototype.alpha=function(r){return"number"==typeof r?x({r:(n=this.rgba).r,g:n.g,b:n.b,a:r}):t(this.rgba.a,2);var n},r}(),x=function(r){return r instanceof N?r:new N(r)},I=[];exports.Colord=N,exports.colord=x,exports.extend=function(r){r.forEach(function(r){I.indexOf(r)<0&&(r(N,c),I.push(r))})};
Object.defineProperty(exports,"__esModule",{value:!0});var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},e=function(r){return{r:n(r.r,0,255),g:n(r.g,0,255),b:n(r.b,0,255),a:n(r.a)}},u=function(r){return{r:t(r.r),g:t(r.g),b:t(r.b),a:t(r.a,2)}},o=/^\s*#?([0-9a-f]{3,8})\s*$/i,a=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},i=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,o=Math.max(t,n,e),a=o-Math.min(t,n,e),i=a?o===t?(n-e)/a:o===n?2+(e-t)/a:4+(t-n)/a:0;return{h:60*(i<0?i+6:i),s:o?a/o*100:0,v:o/255*100,a:u}},s=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var o=Math.floor(t),a=e*(1-n),i=e*(1-(t-o)*n),s=e*(1-(1-t+o)*n),b=o%6;return{r:255*[e,i,a,a,s,e][b],g:255*[s,e,e,i,a,a][b],b:255*[a,a,s,e,e,i][b],a:u}},b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),l:n(r.l,0,100),a:n(r.a)}},h=function(r){return{h:t(r.h),s:t(r.s),l:t(r.l),a:t(r.a,2)}},f=function(r){return s((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},g=function(r){return{h:(t=i(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*),?\s*(-?\d+\.?\d*)%?,?\s*(-?\d+\.?\d*)%?,?\s*(-?\d*\.?\d+)?\s*\)?/i,p=/rgba?\(?\s*(-?\d+),?\s*(-?\d+),?\s*(-?\d+),?\s*(-?\d*\.?\d+)?\s*\)?/i,c={string:[function(r){var t=o.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?parseInt(r[3]+r[3],16)/255:1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?parseInt(r.substr(6,2),16)/255:1}:null:null},function(r){var t=p.exec(r);return t?e({r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:void 0===t[4]?1:Number(t[4])}):null},function(r){var t=l.exec(r);if(!t)return null;var n=b({h:Number(t[1]),s:Number(t[2]),l:Number(t[3]),a:void 0===t[4]?1:Number(t[4])});return f(n)}],object:[function(t){var n=t.r,u=t.g,o=t.b,a=t.a,i=void 0===a?1:a;return r(n)&&r(u)&&r(o)?e({r:Number(n),g:Number(u),b:Number(o),a:Number(i)}):null},function(t){var n=t.h,e=t.s,u=t.l,o=t.a,a=void 0===o?1:o;if(!r(n)||!r(e)||!r(u))return null;var i=b({h:Number(n),s:Number(e),l:Number(u),a:Number(a)});return f(i)},function(t){var e=t.h,u=t.s,o=t.v,a=t.a,i=void 0===a?1:a;if(!r(e)||!r(u)||!r(o))return null;var b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),v:n(r.v,0,100),a:n(r.a)}}({h:Number(e),s:Number(u),v:Number(o),a:Number(i)});return s(b)}]},v=function(r,t){for(var n=0;n<t.length;n++){var e=t[n](r);if(e)return e}return null},d=function(r,t){var e=g(r);return{h:e.h,s:n(e.s+100*t,0,100),l:e.l,a:e.a}},m=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},y=function(r,t){var e=g(r);return{h:e.h,s:e.s,l:n(e.l+100*t,0,100),a:e.a}},N=function(){function r(r){this.parsed=function(r){return"string"==typeof r?v(r,c.string):"object"==typeof r&&null!==r?v(r,c.object):null}(r),this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return t(m(this.rgba),2)},r.prototype.isDark=function(){return m(this.rgba)<.5},r.prototype.isLight=function(){return m(this.rgba)>=.5},r.prototype.toHex=function(){return r=u(this.rgba),n=r.r,e=r.g,o=r.b,s=(i=r.a)<1?a(t(255*i)):"","#"+a(n)+a(e)+a(o)+s;var r,n,e,o,i,s},r.prototype.toRgb=function(){return u(this.rgba)},r.prototype.toRgbString=function(){return r=u(this.rgba),t=r.r,n=r.g,e=r.b,(o=r.a)<1?"rgba("+t+", "+n+", "+e+", "+o+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,o},r.prototype.toHsl=function(){return h(g(this.rgba))},r.prototype.toHslString=function(){return r=h(g(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=i(this.rgba),{h:t(r.h),s:t(r.s),v:t(r.v),a:t(r.a,2)};var r},r.prototype.invert=function(){return x({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),x(d(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),x(d(this.rgba,-r))},r.prototype.grayscale=function(){return x(d(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),x(y(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),x(y(this.rgba,-r))},r.prototype.alpha=function(r){return"number"==typeof r?x({r:(n=this.rgba).r,g:n.g,b:n.b,a:r}):t(this.rgba.a,2);var n},r}(),x=function(r){return r instanceof N?r:new N(r)},I=[];exports.Colord=N,exports.colord=x,exports.extend=function(r){r.forEach(function(r){I.indexOf(r)<0&&(r(N,c),I.push(r))})};
{
"name": "colord",
"version": "1.2.1",
"version": "1.3.0",
"description": "👑 A tiny yet powerful tool for high-performance color manipulations and conversions",

@@ -15,2 +15,4 @@ "keywords": [

"hwb",
"lab",
"lch",
"xyz",

@@ -120,2 +122,6 @@ "css",

{
"path": "dist/plugins/lch.mjs",
"limit": "1.1 KB"
},
{
"path": "dist/plugins/names.mjs",

@@ -122,0 +128,0 @@ "limit": "1.5 KB"

@@ -32,3 +32,3 @@ <div align="center">

- 📦 **Small**: Just **1.5 KB** gzipped ([3x+ lighter](#benchmarks) than **color** and **tinycolor2**)
- 🚀 **Fast**: [2x+ faster](#benchmarks) than **color** and **tinycolor2**
- 🚀 **Fast**: [3x+ faster](#benchmarks) than **color** and **tinycolor2**
- 😍 **Simple**: Chainable API and familiar patterns

@@ -48,7 +48,7 @@ - 💪 **Immutable**: No need to worry about data mutations

| ----------------------------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
| <nobr><b>colord 👑</b></nobr> | <nobr><b>2,274,420</b></nobr> | [![](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 | 717,048 | [![](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 | 956,285 | [![](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 | 637,469 | [![](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 | 900,826 | [![](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) |
| <nobr><b>colord 👑</b></nobr> | <nobr><b>3,620,695</b></nobr> | [![](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 | 760,254 | [![](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 | 1,111,927 | [![](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 | 632,656 | [![](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 | 969,079 | [![](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) |

@@ -87,5 +87,5 @@ 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).

- HWB objects ([via plugin](#plugins))
- LCH objects and strings ([via plugin](#plugins))
- LAB objects ([via plugin](#plugins))
- XYZ objects ([via plugin](#plugins))
- LCH (coming soon)

@@ -248,2 +248,36 @@ ```js

<details>
<summary><b><code>toLch()</code></b> (<b>lch</b> plugin)</summary>
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 }
```
</details>
<details>
<summary><b><code>toLchString()</code></b> (<b>lch</b> plugin)</summary>
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)"
```
</details>
<details>
<summary><b><code>toXyz()</code></b> (<b>xyz</b> plugin)</summary>

@@ -536,2 +570,22 @@

<details>
<summary><b><code>lch</code> (CIE LCH color space)</b> <i>1 KB</i></summary>
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)"
```
</details>
<details>
<summary><b><code>names</code> (CSS color keywords)</b> <i>1.29 KB</i></summary>

@@ -606,4 +660,4 @@

- [x] [LAB](https://www.w3.org/TR/css-color-4/#resolving-lab-lch-values) color space (via plugin)
- [ ] [LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space (via plugin)
- [x] [LCH](https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/) color space (via plugin)
- [ ] CMYK color space (via plugin)
- [ ] Mix colors (via plugin)

@@ -31,2 +31,7 @@ export declare type RgbColor = {

}
export interface LchColor {
l: number;
c: number;
h: number;
}
declare type WithAlpha<O> = O & {

@@ -43,3 +48,4 @@ a: number;

};
export declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor;
export declare type LchaColor = WithAlpha<LchColor>;
export declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor;
export declare type AnyColor = string | ObjectColor;

@@ -46,0 +52,0 @@ export declare type InputObject = Record<string, unknown>;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc