Very simple little php function that returns a black or white colour depending on the darkness of the given html colour.
function fontColour($colour){
$r = hexdec($colour[0].$colour[1]);
$g = hexdec($colour[2].$colour[3]);
$b = hexdec($colour[4].$colour[5]);
$sum = $r+$g+$b;
if($sum>390){ return '000000'; }else{ return 'FFFFFF'; }
}
as i said, simple ![]()
enter a 6 char html background colour and it returns 000000 or FFFFFF for your text.
Comments