Created
April 12, 2015 15:25
-
-
Save imamhidayat92/82f3a2a4821844fc71da to your computer and use it in GitHub Desktop.
Convert RGB to Hex
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 normalize = function(h) { return h.length == 1 ? '0' + h : h; }; | |
var convert = function(r, g, b) { return '#' + normalize(r.toString(16)) + normalize(g.toString(16)) + normalize(b.toString(16)); }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment