From 09ffd539b7e88bcb57c9a851657f43b8d862682c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 13 Mar 2021 14:24:16 +0100 Subject: [PATCH] Fixed: #1572 SVG Export - clipping does not use groups --- CHANGELOG.md | 2 ++ .../flash/exporters/commonshape/SVGExporter.java | 6 ++---- .../decompiler/flash/timeline/Timeline.java | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c1b722a4..9508e3173 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - [#1435] Adding DefineScalingGrid to DefineSprite - [#1488] SVG Export - EmptyStackException when clipping used - [#1584] SVG Import - paths with horizontal/vertical lines and rotation +- [#1572] SVG Export - clipping does not use groups ## [14.2.0] - 2021-03-12 ### Added @@ -2114,6 +2115,7 @@ All notable changes to this project will be documented in this file. [#1435]: https://www.free-decompiler.com/flash/issues/1435 [#1488]: https://www.free-decompiler.com/flash/issues/1488 [#1584]: https://www.free-decompiler.com/flash/issues/1584 +[#1572]: https://www.free-decompiler.com/flash/issues/1572 [#1645]: https://www.free-decompiler.com/flash/issues/1645 [#1639]: https://www.free-decompiler.com/flash/issues/1639 [#1371]: https://www.free-decompiler.com/flash/issues/1371 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java index 26fdcf1d4..6e71496ee 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/SVGExporter.java @@ -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; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 1336e6599..e97f1ea5b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -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); }