[csswg-drafts] [css-color] color-contrast() should support ranges of candidate colors, not just discrete color candidates (#7360)

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

== [css-color] color-contrast() should support ranges of candidate colors, not just discrete color candidates ==
When designers are picking colors to pass a certain contrast ratio, they usually adjust a given coordinate, in a given color space (usually lightness). The current `color-contrast()` syntax only allows providing specific candidate colors, so I worry we will see a lot of this:

```
background: var(--color);
color: color-contrast(var(--color) vs 
 lch(from var(--color) 100% c h),
 lch(from var(--color)  90% c h),
 lch(from var(--color)  80% c h),
 lch(from var(--color)  70% c h),
 lch(from var(--color)  60% c h),
 lch(from var(--color)  50% c h),
 lch(from var(--color)  40% c h),
 lch(from var(--color)  30% c h),
 lch(from var(--color)  20% c h),
 lch(from var(--color)  10% c h),
 lch(from var(--color)   0% c h)
);
```

It would be good if there was a syntax to provide the candidate colors as a range, either by reusing `<gradient>`, or with a watered down microsyntax:
* such as a functional syntax `range(<interpolation-method>, <color>#)` 
 * example: `range(in lch, lch(from var(--color) 100% c h), lch(from var(--color)   0% c h))`) 
* or a keyword-based syntax like `<color> to <color> <interpolation-method>?` 
 * example: `lch(from var(--color) 100% c h) to lch(from var(--color) 0% c h) in lch`

The range would be considered ordered, and browsers would return the first color in the range that passes the target contrast (which they may decide to calculate via binary search). It may make things simpler if ranges can only be from one color to another color.

*(Issue filed following breakout discussions between @svgeesus, @fantasai, @argyleink and myself)*

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


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

Received on Tuesday, 14 June 2022 18:23:18 UTC