0

I need to convert a OLE Color to and from a hex color for the web, kind of like the example here: Convert .Net Color Objects to HEX codes and Back

But the problem is I need to do it in Javascript, so how would I do that?

Community
  • 1
  • 1
Jonathan
  • 1,725
  • 3
  • 19
  • 45

1 Answers1

0

Does JQuery Color fit the bill?

var rgba = $.Color("#ff0000").rgba() gives [255,0,0,1]

You can get a single rgb int (ignoring alpha) out of that with:

(rgba[0] << 16) + (rgba[1] << 8) + rgba[2]
Rob Fonseca-Ensor
  • 15,510
  • 44
  • 57
  • The main thing is I don't see how to get the hex back to a color int. I think I can make the int to hex work. – Jonathan Jan 24 '14 at 18:42