From 46b36328367770ba50607e311d5591c0638c62a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 11 Dec 2022 21:27:49 +0100 Subject: [PATCH] Added Show axis as dashed line in Free transform of sprites --- CHANGELOG.md | 1 + .../decompiler/flash/gui/ImagePanel.java | 62 +++++++++++++------ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b7c63975..ab9f0f000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. - Option to disable autoplay of sounds (DefineSound) - [#1181] Remembering choice of loading assets via importassets tag - [#1900] Free transform whole sprites +- Show axis as dashed line in Free transform of sprites ### Fixed - [#1897] Close menu button without selecting specific item diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 850134313..bde1843d6 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -2392,34 +2392,56 @@ public final class ImagePanel extends JPanel implements MediaDisplay { + Rectangle realRect = new Rectangle(rect.Xmin, rect.Ymin, rect.Xmax-rect.Xmin, rect.Ymax-rect.Ymin); + realRect.x *= zoomDouble; + realRect.y *= zoomDouble; + realRect.width *= zoomDouble; + realRect.height *= zoomDouble; + realRect.x /= SWF.unitDivisor; + realRect.y /= SWF.unitDivisor; + realRect.width /= SWF.unitDivisor; + realRect.height /= SWF.unitDivisor; + + + if (freeTransformDepth > -1) { + realRect.x = -offsetX; + realRect.y = -offsetY; + if (_rect.x < 0) { + realRect.x += _rect.x; + } + if (_rect.y < 0) { + realRect.y += _rect.y; + } + } + + if (!autoPlayed) { img = getImagePlay(); } else if (_viewRect.getHeight() < 0 || _viewRect.getWidth() < 0) { img = new SerializableImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); } else { - Rectangle realRect = new Rectangle(rect.Xmin, rect.Ymin, rect.Xmax-rect.Xmin, rect.Ymax-rect.Ymin); - realRect.x *= zoomDouble; - realRect.y *= zoomDouble; - realRect.width *= zoomDouble; - realRect.height *= zoomDouble; - realRect.x /= SWF.unitDivisor; - realRect.y /= SWF.unitDivisor; - realRect.width /= SWF.unitDivisor; - realRect.height /= SWF.unitDivisor; - - if (freeTransformDepth > -1) { - realRect.x = -offsetX; - realRect.y = -offsetY; - if (_rect.x < 0) { - realRect.x += _rect.x; - } - if (_rect.y < 0) { - realRect.y += _rect.y; - } - } + img = getFrame(realRect, rect, _viewRect, swf, frame, frozen ? 0 : time, timelined, renderContext, selectedDepth, freeTransformDepth, zoomDouble, registrationPointRef, boundsRef, trans2, tempTrans2 == null ? null : new Matrix(tempTrans2)); } + if (!(timelined instanceof SWF) && freeTransformDepth > -1) { + + int axisX = 0; + int axisY = 0; + + axisX = realRect.x - (int)(rect.Xmin* zoomDouble/ SWF.unitDivisor); + axisY = realRect.y - (int)(rect.Ymin* zoomDouble / SWF.unitDivisor ); + + Graphics2D g = (Graphics2D) img.getBufferedImage().getGraphics(); + g.setPaint(Color.black); + g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, new float[]{9}, 0)); + GeneralPath p = new GeneralPath(); + p.moveTo(axisX, 0); + p.lineTo(axisX, getHeight()); + p.moveTo(0, axisY); + p.lineTo(getWidth(), axisY); + g.draw(p); + } /*if(freeTransformDepth > -1) { Graphics2D gg = (Graphics2D)img.getBufferedImage().getGraphics(); gg.setColor(Color.red);