From f9268c0c7a859664dc08cf78b3286eb5cf0f9c38 Mon Sep 17 00:00:00 2001 From: Gregor Aisch Date: Sat, 17 Aug 2024 09:30:10 +0000 Subject: [PATCH] feat: support modern css colors (#347) * feat: add support for modern css colors, beginning with rba and hsl * wip: lab2css * use rgb() and hsl() even if color has alpha != 1 * fix test * feat: support changing the CIELab reference white point * add css lch() export * feat: add css support for oklab and oklch * link to discord in readme * document setLabWhitePoint etc. * fill in changelog * quick n dirty responsive website * remove parsing of css oklab colors for now --- CHANGELOG.md | 21 ++++ docs/bin/post-process | 3 +- docs/src/footer.inc.html | 48 ++++--- docs/src/index.css | 242 +++++++++++++++++++++++++++++++----- docs/src/index.md | 58 +++++++-- readme.md | 4 + src/io/css/css2rgb.js | 89 +++++++++++-- src/io/css/hsl2css.js | 6 +- src/io/css/lab2css.js | 25 ++++ src/io/css/lch2css.js | 25 ++++ src/io/css/oklab2css.js | 17 +++ src/io/css/oklch2css.js | 17 +++ src/io/css/rgb2css.js | 37 +++++- src/io/lab/index.js | 3 + src/io/lab/lab-constants.js | 110 +++++++++++++++- src/io/lab/lab2rgb.js | 98 ++++++++++++--- src/io/lab/rgb2lab.js | 76 +++++++---- src/io/lch/rgb2lch.js | 5 +- src/io/oklab/rgb2oklab.js | 5 +- src/io/oklch/rgb2oklch.js | 5 +- src/utils/unpack.js | 2 +- test/alpha.test.js | 6 +- test/autodetect.test.js | 9 +- test/delta-e.test.js | 2 +- test/io/css2rgb.test.js | 17 ++- test/io/lab2rgb.test.js | 31 +++++ test/io/rgb2css.test.js | 48 +++++-- test/io/rgb2lab.test.js | 18 +++ test/scales.test.js | 8 +- 29 files changed, 894 insertions(+), 141 deletions(-) create mode 100644 src/io/css/lab2css.js create mode 100644 src/io/css/lch2css.js create mode 100644 src/io/css/oklab2css.js create mode 100644 src/io/css/oklch2css.js diff --git a/CHANGELOG.md b/CHANGELOG.md index d6f1f0f7..591b1b99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ ## Changelog +### 3.0.0 +* 🎉 NEW: add support for modern CSS color spaces `lab()`, `lch()`, `oklab()`, `oklch()`. +* 🎉 NEW: you can now control the standard white reference point for the CIE Lab and CIE Lch color spaces. +* chroma.css will no longer return legacy CSS colors like `rgb(255, 255, 0)` but modern CSS colors like `rgb(255 255 0)`. + +### 2.6.0 +* 🎉 NEW: add [`color.shade()`](#color-shade), [`color.tint()`](#color-shade). +* fix: remove false w3c color cornflower + +### 2.5.0 +* refactored code base to ES6 modules + +### 2.4.0 +* add support for Oklab and Oklch color spaces + +### 2.3.0 +* use binom of degree n in chroma.bezier + +### 2.2.0 +* use Delta e2000 for chroma.deltaE #269 + ### 2.0.3 * hsl2rgb will, like other x2rgb conversions now set the default alpha to 1 diff --git a/docs/bin/post-process b/docs/bin/post-process index dab6bf10..4554f6b9 100755 --- a/docs/bin/post-process +++ b/docs/bin/post-process @@ -6,7 +6,8 @@ const footer = fs.readFileSync('src/footer.inc.html', 'utf-8'); let modifiedIndex = index.replace('', '\n'+footer+'\n'); modifiedIndex = modifiedIndex.replace('', ' \n'); -modifiedIndex = modifiedIndex.replace('', '
'); +modifiedIndex = modifiedIndex.replace('', ' \n'); +modifiedIndex = modifiedIndex.replace('', '
'); modifiedIndex = modifiedIndex.replace('', '
'); fs.writeFileSync('index.html', modifiedIndex); diff --git a/docs/src/footer.inc.html b/docs/src/footer.inc.html index 77858721..b93ffbff 100644 --- a/docs/src/footer.inc.html +++ b/docs/src/footer.inc.html @@ -5,6 +5,16 @@