From 7b07072a8e037cba571423e83becd97fe0757fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 10 Dec 2011 14:25:36 +0100 Subject: [PATCH] Slight rewrite of ChatUtil::gradient() --- file/lib/util/ChatUtil.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/file/lib/util/ChatUtil.class.php b/file/lib/util/ChatUtil.class.php index 8bb396c..77ac7ed 100644 --- a/file/lib/util/ChatUtil.class.php +++ b/file/lib/util/ChatUtil.class.php @@ -23,15 +23,17 @@ class ChatUtil { */ public static function gradient($string, $start, $end) { $string = str_split($string); - $r = (int) ((($start >> 16 & 255) - ($end >> 16 & 255)) / (count($string) - 1)); - $g = (int) ((($start >> 8 & 255) - ($end >> 8 & 255)) / (count($string) - 1)); - $b = (int) ((($start & 255) - ($end & 255)) / (count($string) - 1)); + $r = (int) ((($start & 0xFF0000) - ($end & 0xFF0000)) / (count($string) - 1)); + $g = (int) ((($start & 0x00FF00) - ($end & 0x00FF00)) / (count($string) - 1)); + $b = (int) ((($start & 0x0000FF) - ($end & 0x0000FF)) / (count($string) - 1)); $result = ''; for ($i = 0, $max = count($string); $i < $max; $i++) { - $result .= ''.$string[$i].''; + $result .= ''.$string[$i].''; } return $result; } + + }