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

Fixing bug with empty string

This commit is contained in:
Tim Düsterhus 2011-12-14 17:24:41 +01:00
parent 34642d70c8
commit 15a7456aba

View File

@ -31,6 +31,8 @@ class ChatUtil {
*/ */
public static function gradient($string, $start, $end) { public static function gradient($string, $start, $end) {
$string = self::str_split($string); $string = self::str_split($string);
if (count($string) === 0) return '';
$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));