Skip to content

Instantly share code, notes, and snippets.

@GarrettS
Created September 2, 2011 17:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GarrettS/1189225 to your computer and use it in GitHub Desktop.
Save GarrettS/1189225 to your computer and use it in GitHub Desktop.
toHexString = function (r, g, b)
var toHexString = function (r, g, b) {
return (toHexString = _toHexString)(r,g,b);
function _toHexString(r, g, b) {
return "#" + toHexByte(r) + toHexByte(g) + toHexByte(b);
}
function toHexByte(bite) {
var hex = bite.toString(16);
return (hex.length === 2 ? hex : "0" + hex);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment