Repository navigation
Releases
Releases Β· omgovich/colord
v2.14.0
Minor Changes
- New:
labplugin parseslab()strings and addstoLabString()β€οΈ @bardrop
Patch Changes
- Fix: parsing CMYK colors rounds a channel that is exactly half up, so
device-cmyk(0% 0% 0% 90%)is#1a1a1aand not#191919β€οΈ @simonkundrik - Fix: parse plain numbers for saturation/lightness in space-separated
hsl()and for whiteness/blackness inhwb(), such ashsl(120 50 50)andhwb(120 20 30)β€οΈ @bardrop - Fix:
labplugin clamps a lightness above 100 to 100, as CSS Color 4 requires, such as{ l: 130, a: -60, b: 60 }β€οΈ @bardrop - Fix: parse space-separated
rgb()that mixes numbers and percentages, such asrgb(10% 20 30)β€οΈ @bardrop - Fix: HSL, HSV and HWB conversions round a channel that is exactly half up, so
hwb(0 10% 0%)is#ff1a1aas in browsers, not#ff1919;grayscale(),rotate(),saturate(),lighten()andharmonies()may shift such channels one step too β€οΈ @simonkundrik - Fix:
toCmyk()andtoCmykString()round a percent that is exactly half up, so#050808isc: 38, notc: 37
v2.13.0
Minor Changes
- New
relativeoption oflighten,darken,saturateanddesaturatethat scales the current value β€οΈ @EricRovell
Patch Changes
- Parse CSS color function strings faster: the number pattern now matches an integer without backtracking β€οΈ @g4lb
- Fix:
lchplugin clamps a negative chroma to 0 instead of flipping the hue, such aslch(50% -20 30)β€οΈ @bardrop - Fix:
lchplugin parses a plain number lightness and a percentage chroma, such aslch(52.2 72.2 56.2)β€οΈ @Kernel-Hunter - Fix:
minify()no longer picks anhsl()string that rounds to a different color - Fix:
namesplugin no longer treats"constructor"and"__proto__"as valid colors β€οΈ @Kernel-Hunter
v2.12.0
Minor Changes
- Parse numbers in scientific notation (
rgb(1e2 .5e1 0 / 25e-2)), as the CSS spec allows
Patch Changes
- Fix: Parse CSS angle units case-insensitively, so
hsl(0.25TURN 50% 50%)means 90 degrees instead of 0.25 β€οΈ @blueDaydreaming725 - Fix: Keep exact colors at the
mix()endpoints and when only alpha differs, so a mixture into white no longer turns green after.darken()β€οΈ @feritcemkahraman - Fix: Type plugin default imports correctly in ES modules under TypeScript's
node16andnodenextresolution
v2.11.0 (OKLab and OKLCH)
Minor Changes
- New
oklabandoklchplugins to parse and convert OKLab and OKLCH colors (CSS Color 4)
v2.10.1
Patch Changes
- Fix: Read the alpha byte of a HEX color exactly, so
#cc88no longer comes back as#cccc8887β€οΈ @spokodev - Fix: Stop
minifyfrom turning down an alpha hex that holds the color exactly, and from returning nothing at all when every notation is switched off
v2.10 (RGB color mixing)
mix,tints,shadesandtones(mixplugin) now accept an optional interpolation color space. LAB stays the default; pass"rgb"to interpolate RGB channels instead β the way browsers and design tools (such as Figma) composite translucent layers.
import { colord, extend } from "colord";
import mixPlugin from "colord/plugins/mix";
extend([mixPlugin]);
colord("#ff0000").mix("#ffffff", 0.5, "rgb").toHex(); // "#ff8080"
colord("#f0f3f1").mix("#007d40", 0.14, "rgb").toHex(); // "#cee2d8" β same as compositing rgba(0, 125, 64, 0.14) over #f0f3f1
colord("#ff0000").tints(3, "rgb").map((c) => c.toHex()); // ["#ff0000", "#ff8080", "#ffffff"]v2.9 (π Color minification)
- New
minifyplugin adding color string minification utilities.
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"v2.8 (Perceived color difference)
- @EricRovell added
deltamethod to calculate the perceived color difference (CIE Delta E 2000) between two colors. The return value is0if the colors are equal,1if they are entirely different.
colord("#faf0c8").delta("#ffffff"); // 0.148
colord("#3296fa").delta("#197dc8"); // 0.099
colord("#afafaf").delta("#b4b4b4"); // 0.014
colord("#000000").delta("#ffffff"); // 1v2.7 (Tints, tones and shades)
- @EricRovell added new
tints,tonesandshadesmethods tomixplugin.
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"];v2.4 (Color harmonies)
- @EricRovell added a new plugin to perform harmony colors generation.
import { colord, extends } 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("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"]