Created
May 26, 2013 11:11
-
-
Save outrunthewolf/5652481 to your computer and use it in GitHub Desktop.
RGB to Hex javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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