Skip to content

Instantly share code, notes, and snippets.

@examinedliving
Created September 24, 2014 14:42
Show Gist options
  • Save examinedliving/b8a3b1f619cae9501a16 to your computer and use it in GitHub Desktop.
Save examinedliving/b8a3b1f619cae9501a16 to your computer and use it in GitHub Desktop.
rgbToHex
// created from this StackOverflow post: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
function rgbToHex(r,g,b){
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment