culori icon indicating copy to clipboard operation
culori copied to clipboard

Add P3 support to `displayable`

Open ai opened this issue 3 years ago • 2 comments

displayable now supports only sRGB, but we have many P3 screens in Apple ecosystem (and Safari support for P3 colors in CSS).

Can we add displayableP3?

ai avatar Feb 22 '22 04:02 ai

Hi @ai, thanks for the report.

I think it would be a good idea to have a more general inGamut(mode) -> function(color) method that covers all bounded color spaces. This depends on adding the reference ranges for all color spaces:

  • https://github.com/Evercoder/culori/issues/153

You could then write:

const displayableP3 = inGamut('p3');
displayableP3('color(rec2020 1 0.5 0)');

The term displayable has become somewhat of a misnomer now that the gamut has been extended beyond sRGB. When expressed as color(srgb ...), a color can be displayed even if it has components outside the [0, 1] range.

danburzo avatar Feb 22 '22 07:02 danburzo

I like this API 👍

ai avatar Feb 22 '22 12:02 ai