sub downhex { # Coded by: Kage (Kage@DBXML.com) http://ss.dbmxl.com # Copyright (C) 2002-2005 Kage, All Rights Reserved. my ($hexcolor, $degrade) = @_; my (@rgbarray, $digitcounter, $coltemp, $rgblowcount, $collabel, $packout, $coltemp2, $hexvalue); $hexcolor =~ s/\#//; for ($digitcounter=0; $digitcounter<3; $digitcounter++) { $coltemp = substr($hexcolor, 2*$digitcounter, 2); $rgbarray[$digitcounter] = (16 * hex(substr($coltemp, 0, 1)) + hex(substr($coltemp, 1, 1))); } for ($rgblowcount=0; $rgblowcount<3; $rgblowcount++) { if ($rgbarray[$rgblowcount] >= $degrade) { $rgbarray[$rgblowcount] = ($rgbarray[$rgblowcount] - $degrade); } } foreach $collabel (@rgbarray) { if (($collabel >= 0) && ($collabel <= 255)) { $packout = pack "c", $collabel; $collabel = unpack "H2", $packout; if (length($collabel) < 2) { $collabel = "0".$collabel; } $coltemp2 .= $collabel; } else { $coltemp2 = ""; break; # Optional, though it won't work in Strict } } if (length($coltemp2) == 6) { $hexvalue = "#".$coltemp2; } return uc($hexvalue); }