- From: Chris Lilley via GitHub <sysbot+gh@w3.org>
- Date: Tue, 01 Sep 2020 07:17:46 +0000
- To: public-css-archive@w3.org
An update to this issue is long overdue, sorry! @grorg - I wrote a non-normative JavaScript [Sample code for color conversions](https://drafts.csswg.org/css-color-4/#color-conversion-code) appendix, which has been in the spec for a while now. I have used this for generating examples and tests, both in this spec and also in CSS Color 5. It has also been ported by others, eg to SASS. The code is believed correct, but is written to be simple and clear rather than efficient or object oriented. For example, the developer is expected to call functions in the correct order. ```js let myP3 = gam_P3(XYZ_to_lin_P3(lin_sRGB_to_XYZ(lin_sRGB([1,0,0])))); let myLCH = Lab_to_LCH(XYZ_to_Lab(D65_to_D50(lin_sRGB_to_XYZ(lin_sRGB([1,0,0]))))); ``` - Lea and I wrote an object-oriented Color API [color.js](https://colorjs.io/) which is extensible, accepts any CSS color specification from CSS Color 4 (plus some more) and provides easy colorspace conversions. ```js let color= new Color("rgb(100% 0% 0%"); color.p3; color.lch; ``` all the gamma correcting and un-correcting, any chromatic adaptation, is handled automatically. Color difference (deltaE, in assorted flavors), luminance contrast ratio, and interpolation (in various colorspaces) is also available. Lastly, there is control over gamut mapping. It can be used in the browser or on the server, e.g. in Node. - Color.js was presented to the CSS WG in the context of Houdini Typed OM, and it was resolved to make a color object with colorspace conversions, WCAG contrast ratio, etc for Typed OM based on this work. So the API will happen, but as part of Typed OM. -- GitHub Notification of comment by svgeesus Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1248#issuecomment-684508071 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 1 September 2020 07:17:49 UTC