add method getContrastColor()

This commit is contained in:
Uwe Steinmann 2023-02-22 09:59:45 +01:00
parent e21e301ea3
commit 9e6e13a041

View File

@ -355,4 +355,12 @@ class SeedDMS_View_Common {
}
echo "};\n";
} /* }}} */
public static function getContrastColor($hexcolor) { /* {{{ */
$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';
} /* }}} */
}