Closed opatiny closed 2 years ago
In the end, we use the colord
library and convert the colors like this:
import { colord, extend } from 'colord';
import labPlugin from 'colord/plugins/lab';
extend([labPlugin]);
console.log(colord({ r: 255, g: 0, b: 0 }).toLab());
console.log(colord({ l: 50, a: -128, b: -128 }).toRgb());
Find a package that converts LAB color codes into RGB.
Wikipedia article on L*a*b*: https://en.wikipedia.org/wiki/CIELAB_color_space
"The lightness value, L*, also referred to as "Lstar," defines black at 0 and white at 100. The a* axis is relative to the green–red opponent colors, with negative values toward green and positive values toward red. The b* axis represents the blue–yellow opponents, with negative numbers toward blue and positive toward yellow."
"The a and b axes are unbounded, and depending on the reference white they can easily exceed ±150 to cover the human gamut. Nevertheless, software implementations often clamp these values for practical reasons. For instance, if integer math is being used it is common to clamp a and b in the range of −128 to 127."
Possible libraries achieving that: