Skip to content

Instantly share code, notes, and snippets.

@fchristant
Last active November 24, 2017 12:21
Show Gist options
  • Save fchristant/d0d80b64ec0ee1bb3876fc55a657043d to your computer and use it in GitHub Desktop.
Save fchristant/d0d80b64ec0ee1bb3876fc55a657043d to your computer and use it in GitHub Desktop.
PHP getcolorcontrast
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