blend
More color spaces for Dart Sass…
Very much a work in progress.
Based heavily on js functions by
Chris Lilley
and Tab Atkins.
npm install @mirisuzanne/blend --save-dev
Usage
So far, there is very little user-facing API,
and basically no documentation,
but we'll get that fixed.
Here are the basics:
@use '<path/to>/blend';
main {
color: blend.lch(65% 75 0);
background: blend.lch(10% 15 280, 85%);
}
There is only one setting:
@use '<path/to>/blend' with ($gamut-correct: false);
If you want more explicit control,
use <path/to>/blend/sass/lab/lch,
and access functions directly:
lch.to-rgb() does the conversion math on an array of channels
lch.in-gamut() returns either the converted channels
or null for out-of-gamut colors
lch.gamut-correct() uses chroma-reduction to get a color in-gamut
lch.color() takes LCH input and returns a Sass color
based on the chosen form of gamut-correction
Development & Testing
git clone git@github.com:mirisuzanne/blend.git
cd blend
yarn
The demo html & sass are in demo/.
- Change the values of
$channels and $range
to generate a new gradient
- Play with
blend.lch($lch, $a)
for direct access to colors
yarn sass to compile (gradients take ~6s)
yarn test to run the tests
ToDo: