r5666 - trunk/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Jan 26 01:56:44 EST 2009


Author: div0
Date: 2009-01-26 01:56:44 -0500 (Mon, 26 Jan 2009)
New Revision: 5666

Modified:
   trunk/server/rcon.pl
Log:
fix color translation


Modified: trunk/server/rcon.pl
===================================================================
--- trunk/server/rcon.pl	2009-01-25 22:13:28 UTC (rev 5665)
+++ trunk/server/rcon.pl	2009-01-26 06:56:44 UTC (rev 5666)
@@ -128,9 +128,9 @@
 sub color_rgb2basic($)
 {
 	my ($data) = @_;
-	my ($r, $g, $b) = @$data;
-	my $min = [sort ($r, $g, $b)]->[0];
-	my $max = [sort ($r, $g, $b)]->[-1];
+	my ($R, $G, $B) = @$data;
+	my $min = [sort { $a <=> $b } ($R, $G, $B)]->[0];
+	my $max = [sort { $a <=> $b } ($R, $G, $B)]->[-1];
 
 	my $v = $max / 15;
 	my $s = ($max == $min) ? 0 : 1 - $min/$max;
@@ -146,17 +146,17 @@
 	{
 		$h = 0;
 	}
-	elsif($max == $r)
+	elsif($max == $R)
 	{
-		$h = (60 * ($g - $b) / ($max - $min)) % 360;
+		$h = (60 * ($G - $B) / ($max - $min)) % 360;
 	}
-	elsif($max == $g)
+	elsif($max == $G)
 	{
-		$h = (60 * ($b - $r) / ($max - $min)) + 120;
+		$h = (60 * ($B - $R) / ($max - $min)) + 120;
 	}
-	elsif($max == $b)
+	elsif($max == $B)
 	{
-		$h = (60 * ($r - $g) / ($max - $min)) + 240;
+		$h = (60 * ($R - $G) / ($max - $min)) + 240;
 	}
 
 	return 1 if $h < 36;




More information about the nexuiz-commits mailing list