Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about the contrast. rgb < 0.03928 or rgb <= 0.03928 ... #41

Open
thierryc opened this issue Dec 14, 2020 · 6 comments
Open

Question about the contrast. rgb < 0.03928 or rgb <= 0.03928 ... #41

thierryc opened this issue Dec 14, 2020 · 6 comments

Comments

@thierryc
Copy link

Hello and thank you for sharing his project.

I have a little question.

In your script color.js

rgb = rgb < .03928 ? rgb / 12.92 : Math.pow((rgb + .055) / 1.055, 2.4);

Meaning:
if RsRGB < 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4

On the w3c page:

if RsRGB <= 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4

It should be:

rgb = rgb <= .03928 ? rgb / 12.92 : Math.pow((rgb + .055) / 1.055, 2.4);

Or do you change it for any good reason ?

https://www.w3.org/TR/WCAG/#contrast-minimum

@stof
Copy link
Contributor

stof commented Apr 4, 2023

At 0.03928, both formula give the same result (up to the 5th decimal). the W3C formula is meant to be a continuous function. So this should not change much in practice

@Myndex
Copy link

Myndex commented Apr 11, 2023

The old W3C formula was incorrect (0.03928) as it was citing an obsolete reference. It was corrected in WCAG 2.1/2.2 around May 2021.

The correct value is 0.04045

Also, it is for rgb values normalized to 0.0-1.0:

Rlin = Rs <= 0.04045 ? Rs / 12.92 : Math.pow((Rs + .055) / 1.055, 2.4);

OR
Rlin = Rs > 0.04045 ? Math.pow((Rs + .055) / 1.055, 2.4) : Rs / 12.92;

Less than or equal, then it's divided by 12.92, greater than it is the offset power function.

Cheers,

Andrew Somers
W3C Invited Expert

@stof
Copy link
Contributor

stof commented Apr 11, 2023

@Myndex https://www.w3.org/TR/WCAG/#dfn-relative-luminance still gives the value of 0.03928 in WCAG 2.1. It seems to be corrected only in WCAG 2.2: https://www.w3.org/TR/WCAG22/#dfn-relative-luminance

@Myndex
Copy link

Myndex commented Apr 12, 2023

Hi @stof

... https://www.w3.org/TR/WCAG/#dfn-relative-luminance still gives the value of 0.03928 in WCAG 2.1. It seems to be corrected only in WCAG 2.2:

My bad for not providing links.

It is listed in the errata for 2.0 and 2.1:

https://www.w3.org/WAI/WCAG20/errata/#substantive
https://www.w3.org/WAI/WCAG21/errata/#substantive

And the latest corrected 2.1 understanding:

https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum#dfn-relative-luminance

And in MathML

https://www.w3.org/WAI/WCAG21/Understanding/relative-luminance.html

Please let me know if you have any questions.

@stof
Copy link
Contributor

stof commented Apr 12, 2023

Well, given the section defining the relative luminance has nothing mentioning the existence of this errata, it is quite hard to discover it (the only way to discover it would be to read the entire spec AFAICT)

@Myndex
Copy link

Myndex commented Apr 13, 2023

Well, given the section defining the relative luminance has nothing mentioning the existence of this errata, it is quite hard to discover it (the only way to discover it would be to read the entire spec AFAICT)

Hi @stof

Yes, there is no doubt the W3's own site is confusing and hard to navigate¹. Your comments are useful, and this issue is something I'll bring up to leadership.

One of the reasons it was finally corrected is because while it doesn't seem to make any difference in 8 bit color, future color spaces are 10 bit or 12 bit, and it does make a difference for them.

Note ¹ my opinion only in this case, LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants