mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-28 16:35:34 +00:00
Added #1913 Retaining shape exact position(bounds) in SVG export (Can be turned on in advanced settings)
This commit is contained in:
@@ -879,6 +879,10 @@ public final class Configuration {
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> showImportSoundInfo = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("export")
|
||||
public static ConfigurationItem<Boolean> svgRetainBounds = null;
|
||||
|
||||
private enum OSId {
|
||||
WINDOWS, OSX, UNIX
|
||||
}
|
||||
|
||||
@@ -96,8 +96,13 @@ public class SVGExporter {
|
||||
Element svgRoot = _svg.getDocumentElement();
|
||||
svgRoot.setAttribute("xmlns:xlink", xlinkNamespace);
|
||||
if (bounds != null) {
|
||||
svgRoot.setAttribute("width", (bounds.getWidth() / SWF.unitDivisor) + "px");
|
||||
svgRoot.setAttribute("height", (bounds.getHeight() / SWF.unitDivisor) + "px");
|
||||
if (Configuration.svgRetainBounds.get()) {
|
||||
svgRoot.setAttribute("width", (bounds.xMax / SWF.unitDivisor) + "px");
|
||||
svgRoot.setAttribute("height", (bounds.yMax / SWF.unitDivisor) + "px");
|
||||
} else {
|
||||
svgRoot.setAttribute("width", (bounds.getWidth() / SWF.unitDivisor) + "px");
|
||||
svgRoot.setAttribute("height", (bounds.getHeight() / SWF.unitDivisor) + "px");
|
||||
}
|
||||
createDefGroup(bounds, null, zoom);
|
||||
}
|
||||
} catch (ParserConfigurationException ex) {
|
||||
@@ -131,7 +136,12 @@ public class SVGExporter {
|
||||
public final void createDefGroup(ExportRectangle bounds, String id, double zoom) {
|
||||
Element g = _svg.createElement("g");
|
||||
if (bounds != null) {
|
||||
Matrix mat = Matrix.getTranslateInstance(-bounds.xMin, -bounds.yMin);
|
||||
Matrix mat;
|
||||
if (Configuration.svgRetainBounds.get()) {
|
||||
mat = new Matrix();
|
||||
} else {
|
||||
mat = Matrix.getTranslateInstance(-bounds.xMin, -bounds.yMin);
|
||||
}
|
||||
mat.scale(zoom);
|
||||
g.setAttribute("transform", mat.getSvgTransformationString(SWF.unitDivisor, 1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user