Last active
November 24, 2017 12:21
-
-
Save fchristant/d0d80b64ec0ee1bb3876fc55a657043d to your computer and use it in GitHub Desktop.
PHP getcolorcontrast
This file contains hidden or 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
function getcolorcontrast($rgb1, $rgb2) { | |
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef | |
return (getcolorluminance($rgb1[0], $rgb1[1], $rgb1[2]) + 0.05) / (getcolorluminance($rgb2[0], $rgb2[1], $rgb2[2]) + 0.05); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment