mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Svg Importer: Fix handling of getDefinition for color values.
This commit is contained in:
parent
6bbc78eaef
commit
494874ec8f
2 changed files with 18 additions and 17 deletions
|
@ -29,18 +29,20 @@ var GradientStop = this.GradientStop = Base.extend(/** @lends GradientStop# */{
|
|||
* ramp {@default 0}
|
||||
*/
|
||||
initialize: function(arg0, arg1) {
|
||||
if (arg1 === undefined && Array.isArray(arg0)) {
|
||||
// [color, rampPoint]
|
||||
this.setColor(arg0[0]);
|
||||
this.setRampPoint(arg0[1]);
|
||||
} else if (arg0.color) {
|
||||
// stop
|
||||
this.setColor(arg0.color);
|
||||
this.setRampPoint(arg0.rampPoint);
|
||||
} else {
|
||||
// color [, rampPoint]
|
||||
this.setColor(arg0);
|
||||
this.setRampPoint(arg1);
|
||||
if (arg0) {
|
||||
if (arg1 === undefined && Array.isArray(arg0)) {
|
||||
// [color, rampPoint]
|
||||
this.setColor(arg0[0]);
|
||||
this.setRampPoint(arg0[1]);
|
||||
} else if (arg0 && arg0.color) {
|
||||
// stop
|
||||
this.setColor(arg0.color);
|
||||
this.setRampPoint(arg0.rampPoint);
|
||||
} else {
|
||||
// color [, rampPoint]
|
||||
this.setColor(arg0);
|
||||
this.setRampPoint(arg1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -237,8 +237,8 @@ new function() {
|
|||
|
||||
var definitions = {};
|
||||
function getDefinition(value) {
|
||||
var match = value.match(/#([^)']+)/);
|
||||
return definitions[match ? match[1] : value];
|
||||
var match = value.match(/\(#([^)']+)/);
|
||||
return match && definitions[match[1]];
|
||||
}
|
||||
|
||||
var importers = {
|
||||
|
@ -359,9 +359,8 @@ new function() {
|
|||
? parseFloat(value, 10)
|
||||
: entry.type === 'array'
|
||||
? value.split(/[\s,]+/g).map(parseFloat)
|
||||
: entry.type === 'color'
|
||||
? getDefinition(value)
|
||||
: value);
|
||||
: entry.type === 'color' && getDefinition(value)
|
||||
|| value);
|
||||
} else {
|
||||
switch (name) {
|
||||
case 'id':
|
||||
|
|
Loading…
Reference in a new issue