Source of file ColorHelper.php
Size: 0,711 Bytes - Last Modified: 2021-12-23T10:51:54+00:00
/var/www/docs.ssmods.com/process/src/code/colors/ColorHelper.php
1234567891011121314151617181920212223242526 | <?php class ColorHelper { /** * Text Color calculation * From http://www.splitbrain.org/blog/2008-09/18-calculating_color_contrast_with_php * Here is a discussion on that topic: http://stackoverflow.com/questions/1331591/given-a-background-color-black-or-white-text * @param type $color * @return string */ public static function calculate_textcolor($color) { $c = str_replace('#', '', $color); $rgb[0] = hexdec(substr($c, 0, 2)); $rgb[1] = hexdec(substr($c, 2, 2)); $rgb[2] = hexdec(substr($c, 4, 2)); if ($rgb[0]+$rgb[1]+$rgb[2]<382) { return '#fff'; } else { return '#000'; } } } |