Skip to content

Instantly share code, notes, and snippets.

@phac
Created March 2, 2009 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phac/72671 to your computer and use it in GitHub Desktop.
Save phac/72671 to your computer and use it in GitHub Desktop.
var parse_color_str = function(color_str){
var matches = color_str.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i);
if(!matches) return {r:0xff, g:0xff, b:0xff};
return {
r : parseInt(matches[1], 16),
g : parseInt(matches[2], 16),
b : parseInt(matches[3], 16)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment