Skip to content

Commit

Permalink
fix: corrected threshold for luminance (#472)
Browse files Browse the repository at this point in the history
The correct threshold is 0.04045, as recited in the official IEC standard for sRGB. And while it was incorrect (0.03928) for a long time in WCAG2, it was corrected by the W3 AGWG in May 2021. 

Current WCAG 2.1 and 2.2 reflect the correct 0.04045 threshold.

Co-authored-by: Rico Kahler <[email protected]>
  • Loading branch information
Myndex and ricokahler authored Dec 8, 2023
1 parent 439966f commit 85fc150
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/getLuminance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getLuminance(color: string): number {

function f(x: number) {
const channel = x / 255;
return channel <= 0.03928
return channel <= 0.04045
? channel / 12.92
: Math.pow(((channel + 0.055) / 1.055), 2.4);
}
Expand Down

0 comments on commit 85fc150

Please sign in to comment.