Skip to content

Instantly share code, notes, and snippets.

@imamhidayat92
Created April 12, 2015 15:25
Show Gist options
  • Save imamhidayat92/82f3a2a4821844fc71da to your computer and use it in GitHub Desktop.
Save imamhidayat92/82f3a2a4821844fc71da to your computer and use it in GitHub Desktop.
Convert RGB to Hex
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