-
Notifications
You must be signed in to change notification settings - Fork 36
Description
I store original source rgb colors in an array variable, which are taken from the Rgb color space. I then have a user interface that allows a user to manipulate these source colors in the Oklch color space, which then renders the user-manipulated colors back in the Rgb color space.
The problem is that the target never ends up equaling its source even when there is no manipulation of hue, chroma, or luminosity as shown here:
With using clampRgb:
`
culori.clampRgb(culori.rgb(culori.oklch({
"mode": "rgb",
"r": 1,
"g": 1,
"b": 1
})))
{mode: 'rgb', r: 0.9999999608276361, g: 1, b: 1} // Result: expected value of r = 1, but got a value < 1
`
Without using clampRgb:
`
culori.rgb(culori.oklch({
"mode": "rgb",
"r": 1,
"g": 1,
"b": 1
}))
{mode: 'rgb', r: 0.9999999608276361, g: 1.00000000005861, b: 1.0000001062495965} // Result: expected value of g < 1 and b < 1, but got g and b values > 1
`
Why does this matter? Because when a user increases the chroma of pure white, I would expect pure white to stay pure white since it is achromatic. But because of this issue, white can becomes a color (often magenta) when chroma is added.