From b7a1fd630ba5e475828184006a17824156ec0141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 9 Dec 2023 18:51:19 +0100 Subject: [PATCH] Fixed morphshape holes calculation --- .../flash/xfl/shapefixer/MorphShapeFixer.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/MorphShapeFixer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/MorphShapeFixer.java index 6442e7d5a..5e13e9666 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/MorphShapeFixer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/MorphShapeFixer.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.LINESTYLE2; import com.jpexs.decompiler.flash.types.LINESTYLEARRAY; import java.awt.Rectangle; import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.HashSet; @@ -258,17 +259,23 @@ public class MorphShapeFixer extends ShapeFixer { for (int i : closedPaths.keySet()) { GeneralPath region = closedPaths.get(i); - Rectangle r = region.getBounds(); + /*Rectangle r = region.getBounds(); double px; double py; do { px = r.getX() + r.getWidth() * Math.random(); py = r.getY() + r.getHeight() * Math.random(); - } while (!region.contains(px, py)); - - if (!path.contains(px, py)) { - closedHolesI.add(i); - } + } while (!region.contains(px, py));*/ + PathIterator pi = region.getPathIterator(null); + if (!pi.isDone()) { + double[] points = new double[6]; + int type = pi.currentSegment(points); + if (type == PathIterator.SEG_MOVETO) { + if (!path.contains(points[0], points[1])) { + closedHolesI.add(i); + } + } + } } }