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

Wrong number when calculating luminosity? #318

Closed
eric-g-97477 opened this issue Dec 1, 2023 · 1 comment
Closed

Wrong number when calculating luminosity? #318

eric-g-97477 opened this issue Dec 1, 2023 · 1 comment

Comments

@eric-g-97477
Copy link

Looking at color.js, I see the following function:

	luminosity: function () {
		// http://www.w3.org/TR/WCAG20/#relativeluminancedef
		var rgb = this.rgb().color;

		var lum = [];
		for (var i = 0; i < rgb.length; i++) {
			var chan = rgb[i] / 255;
			lum[i] = (chan <= 0.04045) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
		}

		return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
	},

Focusing on (chan <= 0.04045), I looked at http://www.w3.org/TR/WCAG20/#relativeluminancedef and saw if RsRGB <= 0.03928 then R = RsRGB/12.92 else R = ((RsRGB+0.055)/1.055) ^ 2.4

Shouldn't 0.04045 be 0.03928? Or, what is the reason for the discrepancy? I have not understood something?

@ferllings
Copy link
Member

The link is outdated, it should refer to WCAG 2.1.
The value as been adjusted in WCAG 2.1:
https://www.w3.org/TR/WCAG21/#dfn-relative-luminance

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

2 participants