niklasvh/html2canvas — Issue #69: [Enhancement] Generators getColors-function
Author: SunboX
Created: 2012-03-02 19:41:54+00:00
State: open

https://github.com/niklasvh/html2canvas/blob/master/src/Generate.js#L34

current function:

```javascript
function getColors(input) {
var j = -1,
color = '',
chr;
while( j++ < input.length ) {
chr = input.charAt( j );
if (chr === ')') {
color += chr;
steps.push( color );
color = '';
j = input.indexOf(",", j) + 1;
if (j === 0) {
break;
}
// while (j++ < input.length && input.charAt( j ) !== ',') {}
} else {
color += chr;
}
}
}
```

"enhanced"

```javascript
function getColors(input) {
var colors = input.match(/#[a-fA-F0-9]{3,6}|rgb\s*\(\s*\d{0,3}\s*,\s*\d{0,3}\s*,\s*\d{0,3}\s*\)/g),
for(i = 0, len = colors.length; i < len; i+=1)
steps.push(colors[i]);
}
```