Skip to content

Instantly share code, notes, and snippets.

@outrunthewolf
Created May 26, 2013 11:11
Show Gist options
  • Save outrunthewolf/5652481 to your computer and use it in GitHub Desktop.
Save outrunthewolf/5652481 to your computer and use it in GitHub Desktop.
RGB to Hex javascript
var hex = rgb_to_colour(255, 255, 255);
rgb_to_colour: function(r,g,b)
{
return '#' + byte_to_hex(r) + byte_to_hex(g) + byte_to_hex(b);
},
byte_to_hex: function(n)
{
var nybHexString = "0123456789ABCDEF";
return String(nybHexString.substr((n >> 4) & 0x0F,1)) + nybHexString.substr(n & 0x0F,1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment