Talk:HexConverter

You could also use the features already available in the .Net framework (Note: Code below is untested...): import System.Globalization.Numberstyles;

function RGBToHex (color : Color) : String { var red : int = color.r * 255; var green : int = color.g * 255; var blue : int = color.b * 255; return (red << 16 | green << 8 | blue ).ToString("X6"); }; function HexToRGB (color : String) : Color { var parsed : UInt32 = UInt32.Parse(color,HexNumber); var finalColor : Color;

finalColor.r= ((parsed >> 16) % 256) / 255.0; finalColor.g= ((parsed >> 8) % 256) / 255.0; finalColor.b= (parsed % 256) / 255.0; finalColor.a=1.0; return finalColor; };  This should result in less code, that's also more robust. (The parsing accepts leading and trailing whitespace and automatically inserts zeroes if there are missing digits. --KeliHlodversson 15:19, 22 March 2008 (PDT)