mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Improve importGroup() code a bit by directly filling an Item instead of an array first.
This commit is contained in:
parent
1cb6a7fc3c
commit
b1c24e2762
1 changed files with 13 additions and 15 deletions
|
@ -43,27 +43,25 @@ new function() {
|
||||||
// Define importer functions for various SVG node types
|
// Define importer functions for various SVG node types
|
||||||
|
|
||||||
function importGroup(svg, type) {
|
function importGroup(svg, type) {
|
||||||
var items = [],
|
var nodes = svg.childNodes,
|
||||||
nodes = svg.childNodes,
|
compound = type === 'clippath',
|
||||||
compound = type === 'clippath';
|
group = compound ? new CompoundPath() : new Group();
|
||||||
|
|
||||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
var child = nodes[i];
|
var child = nodes[i],
|
||||||
if (child.nodeType == 1) {
|
item;
|
||||||
var item = importSvg(child);
|
if (child.nodeType == 1 && (item = importSvg(child))) {
|
||||||
// If adding compound paths to other compound paths,
|
// If adding CompoundPaths to other CompoundPaths,
|
||||||
// we need to "unbox" them first:
|
// we need to "unbox" them first:
|
||||||
if (item) {
|
if (compound && item instanceof CompoundPath) {
|
||||||
if (compound && item instanceof CompoundPath) {
|
group.addChildren(item.removeChildren());
|
||||||
items.push.apply(items, item.removeChildren());
|
item.remove();
|
||||||
item.remove();
|
} else {
|
||||||
} else {
|
group.addChild(item);
|
||||||
items.push(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new (compound ? CompoundPath : Group)(items);
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
function importPoly(svg, type) {
|
function importPoly(svg, type) {
|
||||||
|
|
Loading…
Reference in a new issue