Re: [csswg-drafts] [css-color-4] Conversion examples give unexpected results (lab -> sRGB, lab -> P3, ...) (#6816)

@romainmenke I don't think there is any problem. It is difficult to discuss as you haven't really highlighted a specific example, but an entire page of innumerable examples. In order to discuss this, I will take a single example from your page: `lab(45% -128 -128)`.

Let's keep in mind that while Safari supports the color syntaxes of `lab`, `srgb`, and `display-p3`, that does not mean your display or Safiar will render their true color. Let's consider the specified example of `lab(45% -128 -128)`. This color is out of gamut for both Display P3 and sRGB.

```py
>>> Color('lab(45% -128 -128)')
color(--lab 45% -128 -128 / 1)
>>> Color('lab(45% -128 -128)').convert('srgb')
color(srgb -0.91497 0.58722 1.2945 / 1)
>>> Color('lab(45% -128 -128)').convert('display-p3')
color(display-p3 -0.80848 0.55319 1.2455 / 1)
```

Not only that, browsers do not yet provide any kind of gamut mapping, so colors that are out of gamut will simply get clipped to fit the current space, and then, if your monitor can't display them, they may be clipped there as well. Considering that the above example is out of gamut in both sRGB and Display P3, and most new macs ship with Display P3 monitors, the above example will not display correctly in Safari on its Display P3 monitor. Below will show you what the colors will actually get clipped to.

```py
>>> Color('lab(45% -128 -128)')
color(--lab 45% -128 -128 / 1)
>>> Color('lab(45% -128 -128)').convert('srgb').clip()
color(srgb 0 0.58722 1 / 1)
>>> Color('lab(45% -128 -128)').convert('display-p3').clip()
color(display-p3 0 0.55319 1 / 1)
```

Clipping in one color space will yield a different color than clipping in another color space. Let's compare a color clipped in sRGB and Display P3:

```py
>>> c = Color('lab(45% -128 -128)')
>>> c.convert('srgb').clip().convert('lab')
color(--lab 59.747% -3.438 -62.586 / 1)
>>> c.convert('display-p3').clip().convert('lab')
color(--lab 57.186% -3.1467 -71.391 / 1)
```

The colors are no longer what you started out with. Hopefully, that explains why they may look different when viewing them on your test page.




-- 
GitHub Notification of comment by facelessuser
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6816#issuecomment-969444674 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 15 November 2021 23:44:12 UTC