Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clampChroma in sRGB: pure blue gives unexpected results #253

Open
StephenHaney opened this issue Jan 16, 2025 · 0 comments
Open

clampChroma in sRGB: pure blue gives unexpected results #253

StephenHaney opened this issue Jan 16, 2025 · 0 comments

Comments

@StephenHaney
Copy link

StephenHaney commented Jan 16, 2025

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? Is there anything we can do to improve our results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant