[csswg-drafts] [css-color-4] Sample color conversion code leads to NaN values (#9477)

nex3 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-4] Sample color conversion code leads to NaN values ==
The sample code for converting from XYZ to OKLab involves taking the cube root of the result of multiplying the XYZ color by the `XYZtoLMS` matrix. This is undefined for negative numbers, and returns `NaN`, despite the fact that the XYZ color space is notionally unbounded and thus could very easily produce negative numbers.

This comes up even with fairly reasonable in-bounds colors. For example, `lab(0.01% 35 1)` is equivalent to `xyz(0.008679770007260038 0.000011070564598794538 -0.0005206593067627204)`, which converts to LMS as `[0.006751691618866409, 0.000022646971037596888, -0.00003832537822546193]`.

Should the LMS logic clamp channels so that they're 0 at minimum? Should it take the cube root of the absolute value and then match the sign afterwards?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9477 using your GitHub account


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

Received on Tuesday, 17 October 2023 00:00:45 UTC