RGB to hex and hex to RGB
Note: both versions of rgbToHex expect integer values for r, g and b, so you’ll need to do your own rounding if you have non-integer values. The following will do to the RGB to hex conversion and add any required zero padding: function componentToHex(c) { var hex = c.toString(16); return hex.length == 1 ? “0” … Read more