Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty clip mask should not be removed in SVG export #974

Closed
iconexperience opened this issue Feb 15, 2016 · 0 comments
Closed

Empty clip mask should not be removed in SVG export #974

iconexperience opened this issue Feb 15, 2016 · 0 comments

Comments

@iconexperience
Copy link
Contributor

If a Group has an empty path as the clip mask, the other child items are not visible. This is the expected behaviour, because the visible area is zero.

But if the Group is exported as SVG, the empty clip mask will be removed and no clipping will be applied at all in the SVG, so all previously hidden child nodes become visible.

Here is a little example:

var g = new Group();
g.addChild(new Path());
g.addChild(new Path.Circle({center: [100, 100], radius: 50, fillColor: "red"}));
g.clipped = true;

console.log(new XMLSerializer().serializeToString(project.exportSVG()));

And here is the Sketch

If you open the SVG output in a browser, you will see that the red circle is displayed. The SVG output is here:

<svg x="0" y="0" width="1705.00012" height="1530.00012" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal">
        <g>
            <path d="M50,100c0,-27.61424 22.38576,-50 50,-50c27.61424,0 50,22.38576 50,50c0,27.61424 -22.38576,50 -50,50c-27.61424,0 -50,-22.38576 -50,-50z" fill="#ff0000"/>
        </g>
    </g>
</svg>

As you can see, the clip mask is gone.

In detail this happens because in SvgExport.js line 72 the function exportSVG() returns null.

To fix this a check if the path is a clip mask could be added in SvgExport.js line 113 like this:

if (segments.length === 0 && !item.isClipMask())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant