You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Indeed, toGamut() was added as an extension of clampChroma() that can be used for any RGB-based color space. However, it implements a slightly different algorithm, based on the one proposed in the CSS Color 4 spec, that allows colors to be "roughly in gamut". This algorithm sacrifices a small bit of hue/lightness in order to obtain a more vivid color, rather than reducing the chroma exclusively.
To make toGamut() work more like clampChroma(), you need to disable this "roughly in gamut" aspect by passing in a JND (just-noticeable difference) argument of zero value:
Due to floating-point operations in the conversion code the return values for hue and lightness aren’t guaranteed to be identical to the values passed, but as you can see they virtually coincide in the // After version.
It's a specifying of the issue #168.
I need to clamp chroma of an oklch color to a color space with saving it's original lightness and hue. Clamping to srgb works like a charm
Notice the lightness and the hue components being perfectly preserved.
But I couldn't find a way to achieve the same result in P3 color space.
Notice the lightness and the hue components being mangled.
clampGamut(space)
doesn't give the expected result as well:Can we have a clampChroma analog for
P3
color space that works as perfect as the one forsrgb
?The text was updated successfully, but these errors were encountered: