Created
September 24, 2014 14:42
-
-
Save examinedliving/b8a3b1f619cae9501a16 to your computer and use it in GitHub Desktop.
rgbToHex
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
// 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