Re: [css-houdini-drafts] [css-typed-om] Color conversion and contrast ratio (#989)

1. Please note that with the [relative color syntax](https://drafts.csswg.org/css-color-5/#relative-colors) described in [css-color-5], converting between color spaces is as simple as e.g. `lch(from var(--mycolor))`, which can also be computed easily via even the old CSSOM.
2. Color contrast described by WCAG is fairly simple to compute in CSS, if we add XYZ support to `color()` as a predefined color space. Relative luminance is just the Y component of XYZ, and contrast ratio is just a ratio of relative luminances + 0.05.
3. Please note that while the WCAG contrast ratio has even made it into government regulations, there is a lot of valid criticism against it, as it produces a lot of false positives and false negatives. [This](https://github.com/w3c/wcag/issues/695) is a great —albeit long— thread about that.

That said, it would be good to have a color-space agnostic `Color` object that supports all the manipulations CSS Color does, though not sure Typed OM is a good place for it. In fact, @svgeesus and I are prototyping such a Color object and plan to release it as a library soonish. It has given us a lot of insight into API decisions for something like this, and I suspect releasing it into the wild will give us a lot more.

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

Received on Friday, 15 May 2020 22:10:35 UTC