Replies: 2 comments 4 replies
-
|
It's because luminance doesn't equal what you think it does. Luminance is the relative luminance and also the Y coordinate in XYZ. That is literally what happens behind the scene: convert to XYZ, return Y. When you set luminance, you set the Y coordinate in XYZ, but XYZ also functions like an RGB color space, where Y controls greens. It's more something scientists noticed that the Y channel also happened to align with luminance. You are probably making the assumption that adjusting luminance is like adjusting the lightness directly, but it is not. |
Beta Was this translation helpful? Give feedback.
-
In color.js, when you "manipulate luminance" you are converting the color to XYZ and then changing the luminance (Y) without changing X or Z. That is probably not what you wanted to do (which, I guess, is to get the same color but lighter or darker). In chroma.js, luminance is the relative brightness, according to the WCAG definition. That means it is only defined for sRGB colors. Color.js calculates it correctly for any colorspace. In chroma.js, when you modify luminance:
It doesn't say what space is used for the interpolation, but it is mixing with either black or white depending on whether the luminance is darker or lighter. If that is what you want, you can also mix colors in color.js. Or you could convert the color to Oklch, set the lightness, and then gamut map back to sRGB. This works because in Oklch the lightness, the hue, and the chroma are all independent. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm sure I'm missing something/not understanding, but I'm trying to understand why I am seeing a big difference when manipulating luminance in color.js vs chroma.js
chroma.js
color.js
Why are these so wildly different colors?
Beta Was this translation helpful? Give feedback.
All reactions