mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
SvgImporter: Simplify creation of clip group.
No need to move group into place in DOM, since we're returning it instead of item.
This commit is contained in:
parent
6475d61c89
commit
af66bccb64
1 changed files with 5 additions and 9 deletions
|
@ -69,13 +69,9 @@ new function() {
|
|||
|| value;
|
||||
}
|
||||
|
||||
function clipItem(item, clip) {
|
||||
var group = new Group(clip);
|
||||
// Make sure group stays in the same place in the DOM as item:
|
||||
group.moveAbove(item);
|
||||
group.addChild(item);
|
||||
group.setClipped(true);
|
||||
return group;
|
||||
function createClipGroup(item, clip) {
|
||||
clip.setClipMask(true);
|
||||
return new Group(clip, item);
|
||||
}
|
||||
|
||||
// Define importer functions for various SVG node types
|
||||
|
@ -386,7 +382,7 @@ new function() {
|
|||
// http://www.w3.org/TR/SVG/masking.html#ClipPathProperty
|
||||
case 'clip-path':
|
||||
var clipPath = getDefinition(value).clone().flatten();
|
||||
item = clipItem(item, clipPath);
|
||||
item = createClipGroup(item, clipPath);
|
||||
break;
|
||||
// http://www.w3.org/TR/SVG/types.html#DataTypeTransformList
|
||||
case 'gradientTransform':
|
||||
|
@ -439,7 +435,7 @@ new function() {
|
|||
rectangle.setSize(size);
|
||||
rectangle.setPoint(0);
|
||||
// TODO: the viewbox does not always need to be clipped
|
||||
item = clipItem(item, new Path.Rectangle(rectangle));
|
||||
item = createClipGroup(item, new Path.Rectangle(rectangle));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue