Correctly handle named colors in gradients

This commit is contained in:
Niklas von Hertzen
2015-03-29 23:20:17 +03:00
parent 4b80102e77
commit a49c3a2320
4 changed files with 16 additions and 6 deletions

View File

@ -42,7 +42,7 @@ function LinearGradientContainer(imageData) {
}
this.colorStops = imageData.args.slice(hasDirection ? 1 : 0).map(function(colorStop) {
var colorStopMatch = colorStop.replace(/transparent/g, 'rgba(0, 0, 0, 0.0)').match(this.stepRegExp);
var colorStopMatch = colorStop.match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)|\w+)\s*(\d{1,3})?(%|px)?/);
return {
color: new Color(colorStopMatch[1]),
stop: colorStopMatch[3] === "%" ? colorStopMatch[2] / 100 : null