Re: [csswg-drafts] [css-color-4] L as `<percentage>` in `lab()` and `oklab()` (#6761)

> I'm not sure I understand what you're finding confusing/inconsistent. If anything, having L use percentages to refer to the range of the component in both cases seems vastly more consistent than forcing authors to remember that L in one case is 0-1 and in another, seemingly identical, case is 0-100 (and in a third case is a 0%-100% range)

Here, let me help.

A color has the following color coordinates (say I found these in some other program and want to use them in CSS)

<table>
<tr><th>CIE Lab</th><td>87.82</td><td>-79.3</td><td>80.99</td</tr>
<tr><th>CIE LCH</th><td>87.82</td><td>113.</td><td>134.4</td</tr>
<tr><th>OK Lab</th><td>0.866</td><td>-0.230</td><td>0.179</td</tr>
<tr><th>OK LCH</th><td>0.866</td><td>0.291</td><td>142.1</td</tr>
</table>

So I have to remember that CSS treats CIE Lightness as a percentage, and that percentages in CIE Lightness map to 0-100 in CSS so okay I slap on a percent sign; but I just use the numbers as-is

`lab(87.82% -79.3 80.99)`
`lch(87.82% 113.3 134.4)`

Now I want to use the OK values so I remember that in CSS (as currently specified) I have to slap on a percent **and also** multiply by 100

`color(oklab 0.866 -0.23 0.179)`

and then I do the OKLCH an, um, does Chroma get multiplied by 100 too?  Does it get a percent? If so, that is a percent of what? Wait should I be scaling `a` and `b` by 100 too? If so should Chroma maybe be scaled by 141.42 (square root of 100^2 + 100^2)?

`oklch(86.6% 29.1 142.1)`
`oklch(86.6% 29.1% 142.1)`
`oklch(86.6% 41.15 142.1)`
`oklch(86.6% 0.291 142.1)`

Currently, for CSS Color 4 the last of those is correct. The chance that people mess this up in one way or another and end up with an off-by-100 error when simply copying colors into CSS is large.

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


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

Received on Tuesday, 26 October 2021 10:19:32 UTC