From 91f938c79eec96162093bcc4855770bccf31e27e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 4 May 2025 14:47:03 +0200 Subject: [PATCH] Fixed: Transforming shape when first edge has no moveTo flag (coordinates 0, 0) --- CHANGELOG.md | 2 +- .../decompiler/flash/gui/PreviewPanel.java | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca0067803..016781ebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,7 @@ All notable changes to this project will be documented in this file. - AS 1/2/3 - Fast switching of scripts causing incorrect caret position remembered - AS 1/2 - Remembering caret position for frames - Cleaner file association -- Editing shape points when first edge has no moveTo flag (coordinates 0, 0) +- Editing shape points / transform when first edge has no moveTo flag (coordinates 0, 0) ### Removed - Windows installer does not associate SWF files anymore as it caused false positives on some AVs. diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index d5f55e291..5a471795c 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -2456,12 +2456,15 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel private void transformSHAPE(Matrix matrix, SHAPE shape, int shapeNum) { int x = 0; int y = 0; + StyleChangeRecord lastStyleChangeRecord = null; + boolean wasMoveTo = false; for (SHAPERECORD rec : shape.shapeRecords) { if (rec instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) rec; + lastStyleChangeRecord = scr; if (scr.stateNewStyles) { transformStyles(matrix, scr.fillStyles, scr.lineStyles, shapeNum); - } + } if (scr.stateMoveTo) { Point nextPoint = new Point(scr.moveDeltaX, scr.moveDeltaY); x = scr.changeX(x); @@ -2469,6 +2472,21 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel Point nextPoint2 = matrix.transform(nextPoint); scr.moveDeltaX = nextPoint2.x; scr.moveDeltaY = nextPoint2.y; + scr.calculateBits(); + wasMoveTo = true; + } + } + + if (((rec instanceof StraightEdgeRecord) || (rec instanceof CurvedEdgeRecord)) && !wasMoveTo) { + if (lastStyleChangeRecord != null) { + Point nextPoint2 = matrix.transform(new Point(x, y)); + if (nextPoint2.x != 0 || nextPoint2.y != 0) { + lastStyleChangeRecord.stateMoveTo = true; + lastStyleChangeRecord.moveDeltaX = nextPoint2.x; + lastStyleChangeRecord.moveDeltaY = nextPoint2.y; + lastStyleChangeRecord.calculateBits(); + wasMoveTo = true; + } } } if (rec instanceof StraightEdgeRecord) {