Open johannesodland opened 2 years ago
display()
takes the same options as serialize()
, one of them is inGamut
, so your example basically works almost as-is:
console.log(display(color, {inGamut: true})):
Side note: I think the current display_space detection will detect Lab as the widest display space even though the screen only supports P3.
CSS.supports('color', 'lab(0% 0 0)')
returns true, whilewindow.matchMedia('(color-gamut: rec2020)')
returns false in Safari 15.5 on a p3 display.
display()
deals with what output formats the browser supports. The idea being that you'd rather let the browser do the gamut mapping if they are able. I wonder if there should be some syntax to do what you expected and check the results of the MQ too.
display()
is great as it is, I didn't mean to file this as a bug :)
I should probably have marked this as a feature request. Forgive my English, it's not my main language 😅
display()
deals with what output formats the browser supports. The idea being that you'd rather let the browser do the gamut mapping if they are able.
I agree in theory, but current browsers aren't that great at mapping colors that are outside the screen/display space atm. Safari seems to clip the colors, and does not follow the standardized CSS gamut mapping method yet. That's why it would be nice to have a syntax to have display()
use one of the color.js gamut mapping methods in stead :)
That way we could have nice gamut mapping, even if browsers haven't implemented the standardised gamut mapping.
It is in no way critical. It is possible to do this already, by converting to the supported device space before serializing.
I wonder if there should be some syntax to do what you expected and check the results of the MQ too.
That would be great 🙏
Awesome library, btw. Can't thank you guys enough 👏
Happy to add such syntax to display()
, the only blocker is that we'd need to come up with a good syntax :)
The
display
method returns color as is if the browser supports the serialized color, even if it is outside the current display space.Gamut mapping is left to the browser as a result. In the current Safari that means gamut clipping, which in turn can lead to shifts in hue or lightness.
It would be nice if the display method had an option to always use color.js gamut mapping to the current display space. Even better if we could control the gamut mapping method.
Example:
Side note: I think the current display_space detection will detect Lab as the widest display space even though the screen only supports P3.
CSS.supports('color', 'lab(0% 0 0)')
returns true, whilewindow.matchMedia('(color-gamut: rec2020)')
returns false in Safari 15.5 on a p3 display.