new algo for contrast color based on lightness

This commit is contained in:
Uwe Steinmann 2023-03-03 16:14:01 +01:00
parent 198dc8c730
commit 39026ef4a8

View File

@ -360,7 +360,12 @@ class SeedDMS_View_Common {
$r = hexdec(substr($hexcolor, 1, 2));
$g = hexdec(substr($hexcolor, 3, 2));
$b = hexdec(substr($hexcolor, 5, 2));
$yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
return ($yiq >= 148) ? '000000' : 'ffffff';
if(0) {
$yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
return ($yiq >= 148) ? '000000' : 'ffffff';
} else {
$l = (max($r, max($g, $b)) + min($r, min($g, $b)))/2;
return ($l > 128) ? '000000' : 'ffffff';
}
} /* }}} */
}