Created
November 9, 2016 07:05
-
-
Save intco/743db4c5a99234abdc5a5d392a8db33b 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
<?php | |
/** | |
* returns dark or light primary color provided the background | |
*/ | |
function cc($backgroundColor, $dark='black', $light='white') { | |
return (hexdec($backgroundColor) > 0xffffff/2) ? $dark : $light; | |
} | |
echo cc('008000')."\n"; | |
echo cc('FFC0CB')."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment