Fixed: #2572 SVG import - incorrect stroke width when transform contains rotation/shear

This commit is contained in:
Jindra Petřík
2025-12-21 23:24:36 +01:00
parent ef9213663c
commit 4777c2a42b
4 changed files with 9 additions and 8 deletions

View File

@@ -28,13 +28,13 @@ import java.awt.geom.Rectangle2D;
*/
public final class Matrix implements Cloneable {
public double scaleX = 1;
public double scaleX = 1; //a
public double scaleY = 1;
public double scaleY = 1; //d
public double rotateSkew0;
public double rotateSkew0; //b
public double rotateSkew1;
public double rotateSkew1; //c
public double translateX;

View File

@@ -107,9 +107,7 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
this.exporter = exporter;
this.displayZoom = displayZoom;
com.jpexs.decompiler.flash.exporters.commonshape.Point p00 = strokeTransformation.transform(0, 0);
com.jpexs.decompiler.flash.exporters.commonshape.Point p11 = strokeTransformation.transform(1, 1);
thicknessScale = p00.distanceTo(p11) / Math.sqrt(2);
thicknessScale = Math.sqrt(Math.abs(strokeTransformation.scaleX * strokeTransformation.scaleY - strokeTransformation.rotateSkew0 * strokeTransformation.rotateSkew1));
}
@Override

View File

@@ -2028,7 +2028,8 @@ public class SvgImporter {
ILINESTYLE lineStyle = shapeNum <= 3 ? new LINESTYLE() : new LINESTYLE2();
lineStyle.setColor(getRGB(shapeNum, lineColor));
double scale = Math.max(transform.scaleX, transform.scaleY);
double scale = Math.sqrt(Math.abs(transform.scaleX * transform.scaleY - transform.rotateSkew0 * transform.rotateSkew1));
lineStyle.setWidth((int) Math.round(style.getStrokeWidth() * scale * SWF.unitDivisor));
SvgLineCap lineCap = style.getStrokeLineCap();
SvgLineJoin lineJoin = style.getStrokeLineJoin();