mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
Avoid CompoundPath#reduce() in SVG path import by improving regular expression that identifies the need for CompoundPath.
This commit is contained in:
parent
e80991658b
commit
0bca1656ac
1 changed files with 9 additions and 4 deletions
|
@ -130,10 +130,15 @@ new function() {
|
|||
}
|
||||
|
||||
function importPath(node) {
|
||||
return new CompoundPath({
|
||||
pathData: node.getAttribute('d'),
|
||||
insert: false
|
||||
}).reduce();
|
||||
// Get the path data, and determine whether it is a compound path or a
|
||||
// normal path based on the amount of moveTo commands inside it.
|
||||
var data = node.getAttribute('d'),
|
||||
param = { pathData: data, insert: false };
|
||||
// If there are multiple moveTo commands or a closePath command followed
|
||||
// by other commands, we have a CompoundPath:
|
||||
return data.match(/m/gi).length > 1 || /z\S+/i.test(data)
|
||||
? new CompoundPath(param)
|
||||
: new Path(param);
|
||||
}
|
||||
|
||||
function importGradient(node, type) {
|
||||
|
|
Loading…
Reference in a new issue