[csswg-drafts] [css-color-5] relative color syntax doesn't specify how to compute channel values (#8499)

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

== [css-color-5] relative color syntax doesn't specify how to compute channel values ==
_I might be overlooking something and I am not sure how to explain the issue fully.
So apologies in advance if this is a bit vague._

----

I think there are a few things that are a bit hand-wavy in the current specification.

```css
#a {
  color: rgb(from rgb(0 0 0 / 50%) alpha 128 128 / 0.1);
}
```

Safari TP and WPT seem to agree that this is : `rgba(128, 128, 128, 0.1)`
Somehow the alpha value of `50%` or `0.5` got converted to `128`.

This makes sense if you consider that `50%` of `255` is `128`.
But I don't think the specification mentions the need for this conversion anywhere.

https://drafts.csswg.org/css-color-5/#relative-RGB

> alpha 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) alpha transparency

So `alpha` should be `0.5`, not `128`.

-----

```css
#b {
  color: hsl(from rgb(128 128 128 / 50%) alpha 50% 50% / 0.1);
}

#c {
  color: hsl(0.5 50% 50% / 0.1);
}
```

`#b` seems to be `rgb(0, 0, 0)` but the reason isn't clear.  
`hsl` should be able to process hue values of type `<number>`.

`#c` has the same number value as I would expect `alpha` to have and it works perfectly fine : `rgba(191, 65, 64, 0.1)`.

-----

What seems to be missing is a conversion table for when channel keywords are used in other channels.

- using `alpha` in a `r`, `g`, `b`, `h`, ...
- using `r`, `g`, ... in `alpha`
- ...


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


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

Received on Sunday, 26 February 2023 22:00:27 UTC