Created
October 30, 2011 16:35
-
-
Save nowk/1326091 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function rgb2hex(rgb) { | |
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); | |
function hex(x) { | |
return ("0" + parseInt(x).toString(16)).slice(-2); | |
} | |
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment