1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Improve output of gradient.

This commit is contained in:
Tim Düsterhus 2013-04-23 16:36:04 +02:00
parent 2c1d016d41
commit 8f9057c7b8

View File

@ -114,6 +114,10 @@ public static function gradient($string, $start, $end) {
$string = self::str_split($string); $string = self::str_split($string);
if (count($string) === 0) return ''; if (count($string) === 0) return '';
if ($start === $end) {
return '<span style="color:rgb('.($start >> 16 & 255).','.($start >> 8 & 255).','.($start & 255).')">'.\wcf\util\StringUtil::encodeHTML($string).'</span>'
}
$r = (int) ((($start >> 16 & 255) - ($end >> 16 & 255)) / (count($string) - 1)); $r = (int) ((($start >> 16 & 255) - ($end >> 16 & 255)) / (count($string) - 1));
$g = (int) ((($start >> 8 & 255) - ($end >> 8 & 255)) / (count($string) - 1)); $g = (int) ((($start >> 8 & 255) - ($end >> 8 & 255)) / (count($string) - 1));
$b = (int) ((($start & 255) - ($end & 255)) / (count($string) - 1)); $b = (int) ((($start & 255) - ($end & 255)) / (count($string) - 1));