mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-30 04:45:12 +00:00
Fixed Morphshape SVG export - closing the stroke
Propagate noClose flag to morphshape linestyles on replace
This commit is contained in:
@@ -45,6 +45,8 @@ public class CanvasMorphShapeExporter extends MorphShapeExporterBase {
|
||||
protected static final String DRAW_COMMAND_L = "L";
|
||||
|
||||
protected static final String DRAW_COMMAND_Q = "Q";
|
||||
|
||||
protected static final String DRAW_COMMAND_Z = "Z";
|
||||
|
||||
protected String currentDrawCommand = "";
|
||||
|
||||
@@ -151,7 +153,10 @@ public class CanvasMorphShapeExporter extends MorphShapeExporterBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endLines() {
|
||||
public void endLines(boolean close) {
|
||||
if (close) {
|
||||
pathData.append(DRAW_COMMAND_Z).append(" ");
|
||||
}
|
||||
finalizePath();
|
||||
}
|
||||
|
||||
@@ -248,7 +253,7 @@ public class CanvasMorphShapeExporter extends MorphShapeExporterBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
thickness /= SWF.unitDivisor;
|
||||
thicknessEnd /= SWF.unitDivisor;
|
||||
|
||||
@@ -67,8 +67,12 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endLines() {
|
||||
finalizePath();
|
||||
public void endLines(boolean close) {
|
||||
if (close) {
|
||||
pathData.append("Z");
|
||||
pathDataEnd.append("Z");
|
||||
}
|
||||
finalizePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +96,7 @@ public abstract class DefaultSVGMorphShapeExporter extends MorphShapeExporterBas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface IMorphShapeExporter {
|
||||
|
||||
public void beginLines();
|
||||
|
||||
public void endLines();
|
||||
public void endLines(boolean close);
|
||||
|
||||
public void beginFill(RGB color, RGB colorEnd);
|
||||
|
||||
@@ -47,7 +47,7 @@ public interface IMorphShapeExporter {
|
||||
|
||||
public void endFill();
|
||||
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit);
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose);
|
||||
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, GRADRECORD[] gradientRecordsEnd, Matrix matrix, Matrix matrixEnd, int spreadMethod, int interpolationMethod, float focalPointRatio, float focalPointRatioEnd);
|
||||
|
||||
|
||||
@@ -395,7 +395,10 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
|
||||
List<IMorphEdge> path = createPathFromEdgeMap(_lineEdgeMaps.get(groupIndex));
|
||||
int posX = Integer.MAX_VALUE;
|
||||
int posY = Integer.MAX_VALUE;
|
||||
int lastMoveToX = posX;
|
||||
int lastMoveToY = posY;
|
||||
int lineStyleIdx = Integer.MAX_VALUE;
|
||||
boolean autoClose = true;
|
||||
if (path.size() > 0) {
|
||||
beginLines();
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
@@ -420,8 +423,13 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
|
||||
int joinStyle = LINESTYLE2.ROUND_JOIN;
|
||||
float miterLimitFactor = 3f;
|
||||
boolean hasFillFlag = false;
|
||||
autoClose = true;
|
||||
if (lineStyle instanceof LINESTYLE2) {
|
||||
LINESTYLE2 lineStyle2 = (LINESTYLE2) lineStyle;
|
||||
|
||||
if (lineStyle2.noClose) {
|
||||
autoClose = false;
|
||||
}
|
||||
if (lineStyle2.noHScaleFlag && lineStyle2.noVScaleFlag) {
|
||||
scaleMode = "NONE";
|
||||
} else if (lineStyle2.noHScaleFlag) {
|
||||
@@ -446,7 +454,9 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
|
||||
startCapStyle,
|
||||
endCapStyle,
|
||||
joinStyle,
|
||||
miterLimitFactor);
|
||||
miterLimitFactor,
|
||||
!autoClose
|
||||
);
|
||||
|
||||
if (hasFillFlag) {
|
||||
LINESTYLE2 lineStyle2 = (LINESTYLE2) lineStyle;
|
||||
@@ -489,11 +499,13 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
|
||||
}
|
||||
} else {
|
||||
// We should never get here
|
||||
lineStyle(1, 1, new RGB(Color.black), new RGB(Color.BLACK), false, "NORMAL", 0, 0, 0, 3);
|
||||
lineStyle(1, 1, new RGB(Color.black), new RGB(Color.BLACK), false, "NORMAL", 0, 0, 0, 3, false);
|
||||
}
|
||||
}
|
||||
if (posX != e.getFromX() || posY != e.getFromY()) {
|
||||
moveTo(e.getFromX(), e.getFromY(), e.getFromEndX(), e.getFromEndY());
|
||||
lastMoveToX = e.getFromX();
|
||||
lastMoveToY = e.getFromY();
|
||||
}
|
||||
if (e instanceof CurvedMorphEdge) {
|
||||
CurvedMorphEdge c = (CurvedMorphEdge) e;
|
||||
@@ -504,7 +516,7 @@ public abstract class MorphShapeExporterBase implements IMorphShapeExporter {
|
||||
posX = e.getToX();
|
||||
posY = e.getToY();
|
||||
}
|
||||
endLines();
|
||||
endLines(autoClose && lastMoveToX == posX && lastMoveToY == posY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public class SVGMorphShapeExporter extends DefaultSVGMorphShapeExporter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, double thicknessEnd, RGB color, RGB colorEnd, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
thickness *= zoom / SWF.unitDivisor;
|
||||
thicknessEnd *= zoom / SWF.unitDivisor;
|
||||
|
||||
@@ -403,7 +403,7 @@ public class BitmapExporter extends ShapeExporterBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
linePaint = null;
|
||||
lineTransform = null;
|
||||
|
||||
@@ -289,7 +289,7 @@ public class CanvasShapeExporter extends ShapeExporterBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
thickness /= SWF.unitDivisor;
|
||||
strokeData.append("\tvar scaleMode = \"").append(scaleMode).append("\";\r\n");
|
||||
|
||||
@@ -109,7 +109,7 @@ public abstract class DefaultSVGShapeExporter extends ShapeExporterBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface IShapeExporter {
|
||||
|
||||
public void endFill();
|
||||
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit);
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose);
|
||||
|
||||
public void lineGradientStyle(int type, GRADRECORD[] gradientRecords, Matrix matrix, int spreadMethod, int interpolationMethod, float focalPointRatio);
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class PathExporter extends ShapeExporterBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
this.thickness = thickness;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
finalizePath();
|
||||
thickness *= zoom / SWF.unitDivisor;
|
||||
path.setAttribute("fill", "none");
|
||||
|
||||
@@ -453,7 +453,9 @@ public abstract class ShapeExporterBase implements IShapeExporter {
|
||||
startCapStyle,
|
||||
endCapStyle,
|
||||
joinStyle,
|
||||
miterLimitFactor);
|
||||
miterLimitFactor,
|
||||
!autoClose
|
||||
);
|
||||
|
||||
if (hasFillFlag) {
|
||||
FillStyle fillStyle = lineStyle.fillType;
|
||||
@@ -485,7 +487,7 @@ public abstract class ShapeExporterBase implements IShapeExporter {
|
||||
}
|
||||
} else {
|
||||
// We should never get here
|
||||
lineStyle(1, new RGB(Color.black), false, "NORMAL", 0, 0, 0, 3);
|
||||
lineStyle(1, new RGB(Color.black), false, "NORMAL", 0, 0, 0, 3, false);
|
||||
}
|
||||
}
|
||||
if (posX != e.getFromX() || posY != e.getFromY()) {
|
||||
|
||||
@@ -304,7 +304,7 @@ public class ShapeForMorphExporter extends ShapeExporterBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit) {
|
||||
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
|
||||
endCurrent();
|
||||
currentLineStyle = lineStyles.size();
|
||||
LINESTYLE2 lineStyle = new LINESTYLE2();
|
||||
@@ -327,6 +327,7 @@ public class ShapeForMorphExporter extends ShapeExporterBase {
|
||||
lineStyle.endCapStyle = endCaps;
|
||||
lineStyle.joinStyle = joints;
|
||||
lineStyle.miterLimitFactor = miterLimit;
|
||||
lineStyle.noClose = noClose;
|
||||
lineStyles.add(lineStyle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user