Re: [w3ctag/design-reviews] Canvas 2D color management (#646)

> What happens when someone paints an e.g. rec2020 color on an sRGB or Display P3 canvas? Is the result gamut mapped? If so, how?
> 
> The input colors (like other inputs) are converted from the input's color space to the canvas's color space using relative colorimetric mapping, which is the "don't do anything fancy" mapping. In your example, the rec2020 color can always be transformed to some pixel in sRGB, but that pixel may have RGB values outside of the 0-to-1 interval. Relative colorimetric intent just clamps the individual color values to 0-to-1.
> 
> This is what happens today in all browsers if the browser, e.g, loads a rec2020 image that uses the full gamut and attempts to display it on a less capable monitor.

Relative Colorimetric is essentially a set of rules for how gamut mapping should happen, not a gamut mapping algorithm. The per-component clamping you describe does conform to RC, but is a very poor implementation of it. E.g. consider the sRGB color `rgb(100% 200% 400%)`. Using per-component clamping, it would just be converted to achromatic white.

That said, Canvas is not the place to define how gamut mapping happens in the Web platform, and there are plans to flesh this out more in CSS Color 4. Meanwhile, please avoid prose that renders implementations non-conformant if they don’t use naïve clamping in the spec (in case there was any).

But beyond *how* gamut mapping happens, there's also the question of *whether* it happens. The current behavior of restricting everything on a canvas to the gamut of the color space it's defined on is reasonable. Using the `colorSpace` argument to just specify a working color space, and allowing both in-gamut and out-of-gamut colors on the canvas also seems reasonable. What was the rationale of going with the first, rather than the second, option? Did you find it satisfies more use cases?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/646#issuecomment-864398991

Received on Saturday, 19 June 2021 14:33:31 UTC