From 85fc150957ed12a545f63439d3e5bd6a6a36c803 Mon Sep 17 00:00:00 2001 From: Myndex Date: Fri, 8 Dec 2023 15:31:03 -0800 Subject: [PATCH] fix: corrected threshold for luminance (#472) 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 --- src/getLuminance.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getLuminance.ts b/src/getLuminance.ts index 9f2f7bd..e316c78 100644 --- a/src/getLuminance.ts +++ b/src/getLuminance.ts @@ -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); }