Fixed: #1572 SVG Export - clipping does not use groups

This commit is contained in:
Jindra Petřík
2021-03-13 14:24:16 +01:00
parent f874d21327
commit 09ffd539b7
3 changed files with 14 additions and 10 deletions

View File

@@ -167,10 +167,8 @@ public class SVGExporter {
public final Element createClipPath(Matrix transform, String id) {
Element group = createSubGroup(id, "clipPath");
Node parent = group.getParentNode();
if (parent instanceof Element) {
Element parentElement = (Element) parent;
group.setAttribute("transform", parentElement.getAttribute("transform"));
if (transform != null) {
group.setAttribute("transform", transform.getSvgTransformationString(SWF.unitDivisor, 1));
}
return group;
}

View File

@@ -1059,14 +1059,13 @@ public class Timeline {
String assetName;
Tag drawableTag = (Tag) drawable;
RECT boundRect = drawable.getRect();
boolean createNew = false;
if (exporter.exportedTags.containsKey(drawableTag)) {
assetName = exporter.exportedTags.get(drawableTag);
} else {
assetName = getTagIdPrefix(drawableTag, exporter);
exporter.exportedTags.put(drawableTag, assetName);
exporter.createDefGroup(new ExportRectangle(boundRect), assetName);
drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1);
exporter.endGroup();
createNew = true;
}
ExportRectangle rect = new ExportRectangle(boundRect);
@@ -1076,13 +1075,18 @@ public class Timeline {
// TODO: if (layer.blendMode > 1)
if (layer.clipDepth > -1) {
String clipName = exporter.getUniqueId("clipPath");
exporter.createClipPath(new Matrix(), clipName);
Matrix mat = new Matrix(layer.matrix);
exporter.createClipPath(mat, clipName);
SvgClip clip = new SvgClip(clipName, layer.clipDepth);
clips.add(clip);
Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix));
exporter.addUse(mat, boundRect, assetName, layer.instanceName, scalingGrid == null ? null : scalingGrid.splitter);
drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1);
exporter.endGroup();
} else {
if (createNew) {
exporter.createDefGroup(new ExportRectangle(boundRect), assetName);
drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1);
exporter.endGroup();
}
Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix));
exporter.addUse(mat, boundRect, assetName, layer.instanceName, scalingGrid == null ? null : scalingGrid.splitter);
}