clampChroma in sRGB: pure blue gives unexpected results
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
We're seeing very unexpected results when using clampChroma with an RGB value like `0, 0, 1`.
Quick example:
```
const pureRGBBlue = rgbToOklch({ mode: 'rgb', r: 0, g: 0, b: 1 });
// {mode: 'oklch', l: 0.4520137183853429, c: 0.31321437166460125, h: 264.052020638055, alpha: undefined}
// this is expected
const clampedBlue = clampChroma(pureRGBBlue, 'oklch', 'rgb');
// {mode: 'oklch', l: 0.4520137183853429, c: 0.2655745880837794, h: 264.052020638055}
// ^^^ unexpected, chroma clamped 0.05 lower (the input value was already valid RGB chroma)
const backToRgb = oklchToRgb(clampedBlue);
// {mode: 'rgb', r: 0, g: 0.19215686274509805, b: 0.9019607843137255, alpha: undefined}
// expected would be 0 0 1
```
Apologies if I'm not understanding something correctly, which is very possible!
Is this related to [#33](https://github.com/d3/d3-color/issues/33)? Is there anything we can do to improve our results?
Contributor guide
Assessment
This issue has not been assessed yet.