Last active
August 29, 2015 14:13
-
-
Save thedustin/0333e22517888cd20d0f to your computer and use it in GitHub Desktop.
Calculate the textcolor (Black or White) by background-color (YIQ-Contrast) [http://24ways.org/2010/calculating-color-contrast/]
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
<?php | |
$fYIQ = (($iRed * 299) + ($iGreen * 587) + ($iBlue * 114)) / 1000; | |
if($fYIQ >= 128){ | |
echo 'Black textcolor.'; | |
} else { | |
echo 'White textcolor.'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment