[csswg-drafts] [css-color-5] could all channel keywords except hue use percentages in relative color syntax? (#7114)

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

== [css-color-5] could all channel keywords except hue use percentages in relative color syntax? ==
> Within a [relative color](https://drafts.csswg.org/css-color-5/#relative-color) syntax [oklch()](https://drafts.csswg.org/css-color-5/#funcdef-oklch) function, the allowed [channel keywords](https://drafts.csswg.org/css-color-5/#channel-keyword)[](https://drafts.csswg.org/css-color-5/#valdef-oklch-l) are:
> l is a [<percentage>](https://drafts.csswg.org/css-values-4/#percentage-value) that corresponds to the [origin color’s](https://drafts.csswg.org/css-color-5/#origin-color)[](https://drafts.csswg.org/css-color-5/#valdef-oklch-c) OKLab Lightness
> c is a [<number>](https://drafts.csswg.org/css-values-4/#number-value) that corresponds to the [origin color’s](https://drafts.csswg.org/css-color-5/#origin-color)[](https://drafts.csswg.org/css-color-5/#valdef-oklch-h) OKLCH chroma
> h is an [<angle>](https://drafts.csswg.org/css-values-4/#angle-value) that corresponds to the [origin color’s](https://drafts.csswg.org/css-color-5/#origin-color) OKLCH hue, normalized to a [0deg, 360deg) range.

also relevant : https://github.com/w3c/csswg-drafts/issues/7064

Having known ranges for the values behind channel keywords makes more uses cases possible.

For example in `oklch` you might want to increase or reduce the chroma but without going out of bounds. This is only possible if you know the maximum possible value.

works today as `l` is a percentage :

```css
/* increase lightness by a fraction of the current lightness */
oklch(from var(--color) calc(l + calc(calc(100% - l) * 0.5)) c h)
```

doesn't work  as `c` is a number :

```css
/* invert chroma */
oklch(from var(--color) l calc(100% - c) h)
```

Currently using hard coded values like `0.45` for `c` in `oklch` but it's tricky to know exactly when to use percentages or numbers and what the bounds are.

Using only percentages and angle (hue) will make this feature easier to use for stylesheet authors.

`c` doesn't have a known maximum value in the specification, but maybe this can be known for a device?

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


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

Received on Tuesday, 8 March 2022 11:55:38 UTC