mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix issues with SVG Import and matrices on groups.
This commit is contained in:
parent
f433423789
commit
691b2f8094
2 changed files with 9 additions and 6 deletions
|
@ -14,7 +14,7 @@
|
|||
<g transform="scale(5) translate(15, 15) rotate(20) skewX(20) skewY(5)" >
|
||||
<rect x="10" y="10" width="5" height="5" fill="firebrick" />
|
||||
<circle r="10" fill="seagreen" stroke="blue"/>
|
||||
<rect x="5" y="5" width="12" height="2" fill="gray" stroke="silver"/>
|
||||
<rect x="5" y="5" width="12" height="2" fill="grey" stroke="silver"/>
|
||||
</g>
|
||||
</svg>
|
||||
<canvas id="canvas" width="500" height="500"></canvas>
|
||||
|
|
|
@ -71,9 +71,10 @@ new function() {
|
|||
function importGroup(node, type) {
|
||||
var nodes = node.childNodes,
|
||||
clip = type === 'clippath',
|
||||
item = clip ? new CompoundPath() : new Group(),
|
||||
item = clip ? new CompoundPath() : new Clip(),
|
||||
project = item._project,
|
||||
currentStyle = project._currentStyle;
|
||||
currentStyle = project._currentStyle,
|
||||
children = [];
|
||||
// Style on items needs to be handled differently than all other items:
|
||||
// We first apply the style to the item, then use it as the project's
|
||||
// currentStyle, so it is used as a default for the creation of all
|
||||
|
@ -85,6 +86,7 @@ new function() {
|
|||
item = applyAttributes(item, node);
|
||||
project._currentStyle = item._style.clone();
|
||||
}
|
||||
// Collect the children in an array and apply them all at once.
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
var childNode = nodes[i],
|
||||
child;
|
||||
|
@ -92,13 +94,14 @@ new function() {
|
|||
// If adding CompoundPaths to other CompoundPaths,
|
||||
// we need to "unbox" them first:
|
||||
if (clip && child._type === 'compound-path') {
|
||||
item.addChildren(child.removeChildren());
|
||||
children.push.apply(children, child.removeChildren());
|
||||
child.remove();
|
||||
} else if (!(child instanceof Symbol)) {
|
||||
item.addChild(child);
|
||||
children.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
item.addChildren(children);
|
||||
// clip paths are reduced (unboxed) and their attributes applied at the
|
||||
// end.
|
||||
if (clip)
|
||||
|
@ -502,7 +505,7 @@ new function() {
|
|||
item = importer && importer(node, type),
|
||||
data = node.getAttribute('data-paper-data');
|
||||
// See importGroup() for an explanation of this filtering:
|
||||
if (item && item._type !== 'group')
|
||||
if (item && !(item instanceof Group))
|
||||
item = applyAttributes(item, node);
|
||||
if (item && data)
|
||||
item._data = JSON.parse(data);
|
||||
|
|
Loading…
Reference in a new issue