Hi all,

Was wondering if anyone knows a way to accurately convert hexadecimal color codes into RGB format?

im currently using this function :

Code:
function getRGB(hexVal) {
  hexVal = hexVal.replace("#", "");
  var tmp =[];
  tmp[0] = parseInt(hexVal.substring(0,2),16);
  tmp[1] = parseInt(hexVal.substring(2,4),16);
  tmp[2] = parseInt(hexVal.substring(4,6),16);
  return tmp; 
}
This has proven to be very inaccurate.. and often results in the complete wrong color (ie. give it #FF00FF(purple) and it will return [255, 255, 0](yellow) )

any help would be much appreciated

Thanks in advance!