Created
March 5, 2016 10:09
-
-
Save maousan/577b476c25486ac3aaf6 to your computer and use it in GitHub Desktop.
parse rgb color
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 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