Re: [css-houdini-drafts] [css-typed-om] Inputs for the CSSColorValue constructors (#1014)

This is a very common issue with any library working with RGB colors. Typically the decision is to go with one of the two and if one wants to use a different range, they need to convert. In [Color.js](https://colorjs.io/docs/the-color-object.html#color-space-and-coordinates) we went with 0-1 for reasons I will detail below, [chroma.js](https://gka.github.io/chroma.js/#chroma) and [d3 Color](https://github.com/d3/d3-color#color_formatRgb) went with 0-255.

I would suggest going with numbers in the 0-1 range, as the 0-255 range is a relic. It originates in using 8 bit for each color component, and seems completely arbitrary otherwise. Note that [`rgb()` is not restricted to 8 bit anymore](https://www.w3.org/TR/css-color-4/#rgb-functions) as it can accept non-integers. Also, all of the new RGB-based colors in Color 4 use 0-1 as well, [including `color(srgb)`](https://www.w3.org/TR/css-color-4/#valdef-color-srgb). The more using > 8 bit per component becomes commonplace, the more arbitrary 0-255 will seem. 0-1 future-proofs this API.

> Something like: `CSSRGB({r: 0, g: 128, b: 255})` or `CSSRGB({rPct: 0, gPct: 50, bPct: 100})` (not personally a fan of the abbreviation but trying to keep it succinct)

This creates unnecessary error conditions: what happens when *both* `r` and `rPct` are specified? 

Stepping back for a bit, speccing Typed OM for colors is a fairly substantial undertaking and it would be good if we could get some consensus on the overall architecture and design decisions before discussing the minutiae of constructor arguments. I know there are many people in the group who would have input on said design decisions and would love to partake, myself and @svgeesus included.

-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/1014#issuecomment-744623354 using your GitHub account


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

Received on Monday, 14 December 2020 18:23:06 UTC