mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
SvgImport: Always create a clip-item when viewBox is specified.
This commit is contained in:
parent
e38a33fd64
commit
68c4541844
1 changed files with 16 additions and 12 deletions
|
@ -465,13 +465,15 @@ new function() {
|
||||||
// viewBox will be applied both to the group that's created for the
|
// viewBox will be applied both to the group that's created for the
|
||||||
// content in SymbolDefinition#item, and the SymbolItem itself.
|
// content in SymbolDefinition#item, and the SymbolItem itself.
|
||||||
var rect = new Rectangle(convertValue(value, 'array')),
|
var rect = new Rectangle(convertValue(value, 'array')),
|
||||||
size = getSize(node, null, null, true);
|
size = getSize(node, null, null, true),
|
||||||
|
group,
|
||||||
|
matrix;
|
||||||
if (item instanceof Group) {
|
if (item instanceof Group) {
|
||||||
// This is either a top-level svg node, or the container for a
|
// This is either a top-level svg node, or the container for a
|
||||||
// symbol.
|
// symbol.
|
||||||
var scale = size ? rect.getSize().divide(size) : 1,
|
var scale = size ? size.divide(rect.getSize()) : 1,
|
||||||
matrix = new Matrix().translate(rect.getPoint()).scale(scale);
|
matrix = new Matrix().scale(scale).translate(rect.getPoint().negate());
|
||||||
item.transform(matrix.invert());
|
group = item;
|
||||||
} else if (item instanceof SymbolDefinition) {
|
} else if (item instanceof SymbolDefinition) {
|
||||||
// The symbol is wrapping a group. Note that viewBox was already
|
// The symbol is wrapping a group. Note that viewBox was already
|
||||||
// applied to the group, and the above code was executed for it.
|
// applied to the group, and the above code was executed for it.
|
||||||
|
@ -481,15 +483,17 @@ new function() {
|
||||||
// children are added, for styling reasons. See importGroup()
|
// children are added, for styling reasons. See importGroup()
|
||||||
if (size)
|
if (size)
|
||||||
rect.setSize(size);
|
rect.setSize(size);
|
||||||
var clip = getAttribute(node, 'overflow', styles) != 'visible',
|
group = item._item;
|
||||||
group = item._item;
|
|
||||||
if (clip && !rect.contains(group.getBounds())) {
|
|
||||||
// Add a clip path at the top of this symbol's group
|
|
||||||
clip = new Shape.Rectangle(rect).transform(group._matrix);
|
|
||||||
clip.setClipMask(true);
|
|
||||||
group.addChild(clip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
var clip = getAttribute(node, 'overflow', styles) != 'visible';
|
||||||
|
if (clip && !rect.contains(group.getBounds())) {
|
||||||
|
// Add a clip path at the top of this symbol's group
|
||||||
|
clip = new Shape.Rectangle(rect).transform(group._matrix);
|
||||||
|
clip.setClipMask(true);
|
||||||
|
group.addChild(clip);
|
||||||
|
}
|
||||||
|
if (matrix)
|
||||||
|
group.transform(matrix);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue