- From: Kai Ninomiya via GitHub <sysbot+gh@w3.org>
- Date: Fri, 27 May 2022 02:00:35 +0000
- To: public-css-archive@w3.org
kainino0x has just submitted a new pull request for https://github.com/w3c/csswg-drafts: == [css-color-4] Use exact values for some matrices in conversions.js == These color space conversion matrices have exact rational values that can be computed from the numbers provided in the spec. Using exact values is more succinct for most of these matrices, and also makes it a nice reference implementation for other languages. This example code already uses exact inline formulations for a number of other things, like D50 and D65 definitions, so this is similar to that. I'm not really an expert in this, so if this doesn't make sense (e.g. the source values aren't actually exact to begin with) let me know. I checked that these ratios generate values very close to the current ones, usually differing in the last few digits, but double-checking can't hurt. I only did the XYZ conversion matrices for srgb, display-p3, a98-rgb, and rec2020. - I don't have code to easily compute the D65/D50 conversions or OKLab/OKLCH as I was only interested in the predefined color spaces. - The rational forms of prophoto-rgb's matrices exceed the precision of JavaScript math. I could include them as comments though. Source to compute these: https://github.com/kainino0x/exact_css_xyz_matrices using this Rust crate: https://crates.io/crates/rgb_derivation as described for sRGB on this page: https://mina86.com/2019/srgb-xyz-matrix/ but using the numbers from this spec. I used these in the WebGPU conformance test suite: https://github.com/gpuweb/cts/pull/1089 WebGPU needed only srgb and display-p3, but it was easy to extend to the other predefined color spaces. (WebGPU may add some of those color spaces eventually anyway.) See https://github.com/w3c/csswg-drafts/pull/7320 -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 27 May 2022 02:00:36 UTC