From 8f9057c7b83cec29c90ca53c470ce37cc1cb0a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 23 Apr 2013 16:36:04 +0200 Subject: [PATCH] Improve output of gradient. --- file/lib/util/ChatUtil.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/file/lib/util/ChatUtil.class.php b/file/lib/util/ChatUtil.class.php index 7336d97..87eab8a 100644 --- a/file/lib/util/ChatUtil.class.php +++ b/file/lib/util/ChatUtil.class.php @@ -114,6 +114,10 @@ public static function gradient($string, $start, $end) { $string = self::str_split($string); if (count($string) === 0) return ''; + if ($start === $end) { + return ''.\wcf\util\StringUtil::encodeHTML($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));