Created
November 7, 2020 13:13
-
-
Save karenying/2cdc07545ecda1e2919ff2a2157afdc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calculates contrast ratio between two hex strings | |
export function contrastRatioPair(hex1, hex2) { | |
const lum1 = getLuminance(hex1); | |
const lum2 = getLuminance(hex2); | |
return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment