- From: Andrew Somers via GitHub <sysbot+gh@w3.org>
- Date: Tue, 09 Aug 2022 17:59:23 +0000
- To: public-css-archive@w3.org
Hi @LeaVerou and @svgeesus > _...unless they really are that bad._ In the context of the black/white page, both the unmodified Weber and Michelson have a polarity sensitive issue, as neither are perceptually uniform. While both are useful in research relating to the JND, neither are useful for practical design guidance for supra-threshold contrasts. I evaluated these and all other available contrast models in 2019, along with many variants (some of which I mention later in this post). As for the black and white flip page: ```js Weber: (lighter - darker) / darker Michelson: (lighter - darker) / (lighter + darker) ``` So if white is 1 and black is 0, we can see why both of these fail to define a useful "flip point". ### For White: ```js Weber: (1.0 - color) / color Michelson: (1.0 - color) / (1.0 + color) ``` ### For Black: ```js Weber: (color - 0) / 0 Michelson: (color - 0) / (color + 0) ``` So, as we can see for black, Weber produces infinity and Michelson = 1, and in both cases white vs any color will never be the higher compared to black vs any color. ### Regarding the infinity fix: in Weber.js, there is: ```js return Y2 === 0 ? 0 : (Y1 - Y2) / Y2; ``` To fix devide by 0, which would be infinity. But in returning 0, it hides that the actual result should be a _maximum_. As a result, in the black/white page, the Weber shows white text, when in reality it should show black text for all cases similar to Michelson, due to the nature of these algorithms. If I may suggest to consider instead: ```js return Y2 === 0 ? 50000 : (Y1 - Y2) / Y2; ``` The reason: the darkest sRGB color above black is `#000001` and this produces a plain Weber contrast of ~45647. So, setting the divide-by-zero result at 50000 is a reasonable max clamp for the plain Weber. ----- ## Bonus Round! I don't know if you want to play with these, but there are other variants, some are interesting, and we evaluated all of them in 2019. Among the variants is a couple modified Webers where a brute-forced offset is added to the denominator. Sometimes this is claimed to be a "flare" component, but in reality is in effect a "push" to a suprathreshold level. ### _Three Mod Webers_ These assume Y is 0.0 to 1.0: ```js hwangPeli = (Y1 - Y2) / (Y2 + 0.05); somersB = ((Y1 - Y2) / (Y2 + 0.1)) * 0.9; somersE = (Y1 - Y2) / (Y2 + 0.35); ``` However these do not track polarity changes particularly well, and have a mid-range "bump". ### 𝜟𝜱✴︎ (delta phi star) A better and interesting modification is this delta L* variant we created on the path toward SACAM (and APCA). Here, create Lstar from the piecewise sRGB->Y and L* per the standard CIE math, then: ```js deltaPhiStar = (bgLstar^1.618 - txLstar^1.618)^0.618; ``` This mainly works for "Light Mode" but does not track dark mode quite as well. Also, while this is close to parity with light mode APCA at Lc +90, lower contrasts are over-reported, and it does not match in dark mode. Some of this can be addressed with scales and offsets. Nevertheless, I thought you might find these variants interesting. APCA builds on these early experiments, but has added value in terms of polarity sensitivity and wider range for better guideline thresholds. ### _Double Bonus Round_ Regarding the simple concept of a black/white flip, I have this interactive demo-page: [ **_FlipForColor_** ](https://www.myndex.com/WEB/FlipForColor) which includes a brief discussion. For a deeer dive, there is a [CodePen](https://codepen.io/myndex/pen/GRyxrrm), and a [Repo](https://github.com/Myndex/fancyfontflipping), and a [Gist](https://gist.github.com/Myndex/e1025706436736166561d339fd667493#lets-flip-for-color) that discusses this and related issues including font size and weight as it relates to flipping. Thank you for reading -- GitHub Notification of comment by Myndex Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7357#issuecomment-1209700197 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 9 August 2022 17:59:25 UTC