Re: [csswg-drafts] [css-color-6] `contrast-color()` MVP in Level 5 (#9166)

Me, @stubbornella, and a few of our color-related implementors discussed this yesterday.

The plan we'd like to get WG approval for is to, for now, pursue the simplest "output a color that contrasts with this input color" use-case. The other aspects the WG has discussed are important and we want to address them, but we believe we can make valuable incremental progress here without blocking ourselves in the future.

Exact proposal (loosely worded):

-----------

```
contrast-color(<color> max?)
```

Produces a "very light" or "very dark" color, which will contrast well with the input color. The precise algorithm for determining whether to output a light or dark color is UA-defined, as is the precise color produced. However, the output must be within X distance (delta-E units, presumably?) of white or black, and must be opaque. If `max` is specified, the output must be `white` or `black`. The output must make the same "very light" or "very dark" choice whether `max` is specified or not; that is, if it would produce `black` when `max` is specified, then it must produce a "very dark" color when it's not specified, etc.

---------

This definition allows for *some* UA intervention and tweaking over time, producing near-black or near-white grays, or mixing in a little bit of the input hue, if the UA determines that would give the best result. By guaranteeing that the color is nearly black or white, we limit the potential for undesirable clashes (even if you mix in some hue, the maximum possible chroma is drastically limited), and limit the space of possible inputs that could produce a dramatically different result in different UAs, or the same UA over time. We believe this should be sufficient to avoid freezing on a particular algorithm and forcing future us to specify it. 

If the author wants complete control over how they're tweaking their color, `max` gives them assurances of the output, so they can use color-adjust() or color-mix() to very slightly tweak the opacity or mix in a hue of their choice. Or they just get a guaranteed, clean black or white, if that's what they'd prefer.

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


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

Received on Wednesday, 6 September 2023 19:33:59 UTC