hue /= 85;
if (hue <= 1) { g = hue ; r = 1-g; b = 0;}
else if (hue <= 2) { b = hue-1; g = 1-b; r = 0;}
else { r = hue-2; b = 1-r; g = 0;}

$hue = ($hue / 85);
if ($hue <= 1) { $color_g = $hue; $color_r = (1 - $color_g); $color_b = 0; }
elsif ($hue <= 2) { $color_b = ($hue - 1); $color_g = (1 - $color_b); $color_r = 0; }
else { $color_red = ($hue - 2); $color_b = (1-$color_r); $color_g=0; }
