Skip to content
Snippets Groups Projects
Commit 4fa5448a authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

FIX Detection of color brightness

parent e416ea27
No related branches found
No related tags found
No related merge requests found
......@@ -604,10 +604,22 @@ class FormOther
$textcolor='FFF';
if ($color)
{
$hex=$color;
$r = hexdec($hex[0].$hex[1]);
$g = hexdec($hex[2].$hex[3]);
$b = hexdec($hex[4].$hex[5]);
$tmp=explode(',', $color);
if (count($tmp) > 1) // This is a comma RGB ('255','255','255')
{
$r = $tmp[0];
$g = $tmp[1];
$b = $tmp[2];
}
else
{
$hexr=$color[0].$color[1];
$hexg=$color[2].$color[3];
$hexb=$color[4].$color[5];
$r = hexdec($hexr);
$g = hexdec($hexg);
$b = hexdec($hexb);
}
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
if ($bright > 0.6) $textcolor='000';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment