Skip to content

Instantly share code, notes, and snippets.

@maousan
Created March 5, 2016 10:09
Show Gist options
  • Select an option

  • Save maousan/577b476c25486ac3aaf6 to your computer and use it in GitHub Desktop.

Select an option

Save maousan/577b476c25486ac3aaf6 to your computer and use it in GitHub Desktop.
parse rgb color
function parseColor(color, toNum) {
var rcolor = /[\d\.]+/g;
var components = typeof color == "string" ? color.match(rcolor) : null;
if (toNum) {
for (var i = components.length - 1; i >= 0; i--) {
components[i] = parseFloat(components[i]);
}
}
return components;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment