Skip to content

Instantly share code, notes, and snippets.

@fedecarg
Created March 7, 2013 13:08
Show Gist options
  • Save fedecarg/5107924 to your computer and use it in GitHub Desktop.
Save fedecarg/5107924 to your computer and use it in GitHub Desktop.
RGB to hexadecimal converter in 3 lines of code
function rgbToHex(r, g, b) {
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment