From a26d12df65f03aa7ff19a8468600c163b3ed0f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 7 Mar 2021 17:47:20 +0100 Subject: [PATCH] SVG export - 9 slice scaling - parts are grouped and got instanceName --- .../exporters/commonshape/SVGExporter.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) 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 6edfd4ac5..26fdcf1d4 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 @@ -231,6 +231,9 @@ public class SVGExporter { } private void addScalingGridUse(Matrix transform, RECT boundRect, String href, String instanceName, RECT scalingRect) { + + Element image = _svg.createElement("g"); + ExportRectangle exRect = new ExportRectangle(boundRect); ExportRectangle newRect = exRect; if (transform == null) { @@ -259,7 +262,7 @@ public class SVGExporter { + "L 0," + Math.rint(scalingRect.Ymin / (double) SWF.unitDivisor) + " Z" )); leftTopCorner.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(leftTopCorner); + image.appendChild(leftTopCorner); Element bottomLeftCorner = _svg.createElement("use"); transform2 = transform.clone(); @@ -273,7 +276,7 @@ public class SVGExporter { )); bottomLeftCorner.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(bottomLeftCorner); + image.appendChild(bottomLeftCorner); Element topRightCorner = _svg.createElement("use"); transform2 = transform.clone(); @@ -286,7 +289,7 @@ public class SVGExporter { + "L " + Math.rint((boundRect.getWidth() - (exRect.xMax - scalingRect.Xmax)) / (double) SWF.unitDivisor) + "," + Math.rint(scalingRect.Ymin / (double) SWF.unitDivisor) + " Z" )); topRightCorner.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(topRightCorner); + image.appendChild(topRightCorner); Element bottomRightCorner = _svg.createElement("use"); transform2 = transform.clone(); @@ -300,7 +303,7 @@ public class SVGExporter { + "L " + Math.rint((boundRect.getWidth() - (exRect.xMax - scalingRect.Xmax)) / (double) SWF.unitDivisor) + "," + Math.rint(boundRect.getHeight() / (double) SWF.unitDivisor) + " Z" )); bottomRightCorner.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(bottomRightCorner); + image.appendChild(bottomRightCorner); Element top = _svg.createElement("use"); transform2 = transform.clone(); @@ -319,7 +322,7 @@ public class SVGExporter { )); top.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(top); + image.appendChild(top); Element left = _svg.createElement("use"); transform2 = transform.clone(); @@ -337,7 +340,7 @@ public class SVGExporter { )); left.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(left); + image.appendChild(left); Element bottom = _svg.createElement("use"); transform2 = transform.clone(); @@ -357,7 +360,7 @@ public class SVGExporter { )); bottom.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(bottom); + image.appendChild(bottom); Element right = _svg.createElement("use"); transform2 = transform.clone(); @@ -377,7 +380,7 @@ public class SVGExporter { )); right.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(right); + image.appendChild(right); Element center = _svg.createElement("use"); @@ -397,9 +400,12 @@ public class SVGExporter { )); center.setAttribute("xlink:href", "#" + href); - _svgGs.peek().appendChild(center); + image.appendChild(center); - //TODO: how to include instance name + if (instanceName != null) { + image.setAttribute("id", instanceName); + } + _svgGs.peek().appendChild(image); } public Element addUse(Matrix transform, RECT boundRect, String href, String instanceName, RECT scalingRect) {