Welcome to WebmasterWorld Guest from 18.104.22.168
So, does anyone know how I can check this.
You need to know how the hexadecimal system works :)
Thank you very much in advance.
Each element will be between 0 and 255 of course. The tricky part will be deciding what 'dark' is, since a color like blue for example even at 255 would alway look good with white text, but a 255 green might look better with white, then you have combinations etc..
Now if you are dealing with just shades of gray it would be easier. I would split it around 150 for the white/black text decision.
Maybe try this something like this:
// returns brightness value from 0 to 255
// strip off any leading #
$hex = str_replace('#', '', $hex);
$c_r = hexdec(substr($hex, 0, 2));
$c_g = hexdec(substr($hex, 2, 2));
$c_b = hexdec(substr($hex, 4, 2));
return (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
$color = "#******";
if ($get_brightness($color) > 130) // will have to experiment with this number
echo '<font style="color:black;">Black</font>';
echo '<font style="color:white;">White</font>';
Color difference is determined by the following formula:
(maximum (Red value 1, Red value 2) - minimum (Red value 1, Red value 2)) + (maximum (Green value 1, Green value 2) - minimum (Green value 1, Green value 2)) + (maximum (Blue value 1, Blue value 2) - minimum (Blue value 1, Blue value 2))
The rage for color brightness difference is 125. The range for color difference is 500.