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

@atanassov  wrote:

> Further, it would be great to have a function that enables contrast ratio calc given any two colors. The expectations for color contrast described by WCAG are rather detailed and lack developer ergonomics

The WCAG contrast ratio is detailed enough, for sRGB only, but lacks explanation. However it is easy to work out what is being done - the relative, D65-adapted XYZ is calculated for the two colors and the luminance (Y) is used to calculate the contrast.

Given that, it is trivial to extend to other RGB spaces (whether they use D65 or not) and to XYZ, Lab and LCH. Color.js does this, so you can ask for a contrast ratio between any pair of colors regardless of what colorspace each was originally specified in.

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


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

Received on Monday, 17 May 2021 13:27:39 UTC