From b527c3d1fa0fa901ca34f7b52df832ae097cc67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 13 Nov 2022 20:45:05 +0100 Subject: [PATCH] Fixed #1678 Miter join --- CHANGELOG.md | 3 ++- .../flash/exporters/shape/BitmapExporter.java | 2 +- .../exporters/shape/MiterClipBasicStroke.java | 24 +++++++------------ 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f102d2a5d..21d61d4c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ All notable changes to this project will be documented in this file. - [#1846] blend modes with alpha - Raw editor does not select item in enum list - Sound not played on frames +- [#1678] Miter join ### Changed - Full path inside bundle is displayed as SWF name instead simple name @@ -2567,6 +2568,7 @@ All notable changes to this project will be documented in this file. [#1863]: https://www.free-decompiler.com/flash/issues/1863 [#1865]: https://www.free-decompiler.com/flash/issues/1865 [#1846]: https://www.free-decompiler.com/flash/issues/1846 +[#1678]: https://www.free-decompiler.com/flash/issues/1678 [#1414]: https://www.free-decompiler.com/flash/issues/1414 [#1755]: https://www.free-decompiler.com/flash/issues/1755 [#1460]: https://www.free-decompiler.com/flash/issues/1460 @@ -2643,7 +2645,6 @@ All notable changes to this project will be documented in this file. [#1671]: https://www.free-decompiler.com/flash/issues/1671 [#1672]: https://www.free-decompiler.com/flash/issues/1672 [#1677]: https://www.free-decompiler.com/flash/issues/1677 -[#1678]: https://www.free-decompiler.com/flash/issues/1678 [#1665]: https://www.free-decompiler.com/flash/issues/1665 [#1661]: https://www.free-decompiler.com/flash/issues/1661 [#1435]: https://www.free-decompiler.com/flash/issues/1435 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java index 6595e9b50..c2186e150 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/BitmapExporter.java @@ -440,7 +440,7 @@ public class BitmapExporter extends ShapeExporterBase { if (joinStyle == BasicStroke.JOIN_MITER) { lineStroke = new BasicStroke((float) thickness, capStyle, joinStyle, miterLimit); - //lineStroke = new MiterClipBasicStroke((BasicStroke) lineStroke); + lineStroke = new MiterClipBasicStroke((BasicStroke) lineStroke); } else { lineStroke = new BasicStroke((float) thickness, capStyle, joinStyle); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/MiterClipBasicStroke.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/MiterClipBasicStroke.java index e8bfd3c95..a11cc0a64 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/MiterClipBasicStroke.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/shape/MiterClipBasicStroke.java @@ -151,12 +151,12 @@ public class MiterClipBasicStroke implements Stroke { } for (int i = 0; i < vectors.size() - 1; i++) { - if (offPath.get(i)) { + if (offPath.get(i) || offPath.get(i + 1)) { continue; } Vector u = vectors.get(i).transform(t); Vector v = vectors.get(i + 1).transform(t); - + float parallelSign = 1; float dx = u.x2 - u.x1; float dy = u.y2 - u.y1; @@ -194,23 +194,15 @@ public class MiterClipBasicStroke implements Stroke { intersectX = perp2.x1; float line_a = (perp1.y2 - perp1.y1) / (perp1.x2 - perp1.x1); float line_c = perp1.y1 - line_a * perp1.x1; - intersectY = line_a * intersectX + line_c; - } else if (perp1.y1 == perp1.y2) { - intersectY = perp1.y1; - float line_b = (perp2.y2 - perp2.y1) / (perp2.x2 - perp2.x1); - float line_d = perp2.y1 - line_b * perp2.x1; - intersectX = (intersectY - line_d) / line_b; - } else if (perp2.y1 == perp2.y2) { - intersectY = perp2.y1; - float line_a = (perp1.y2 - perp1.y1) / (perp1.x2 - perp1.x1); - float line_c = perp1.y1 - line_a * perp1.x1; - intersectX = intersectY - line_c / line_a; - } else { + intersectY = line_a * intersectX + line_c; + } else { + //y = a x + c float line_a = (perp1.y2 - perp1.y1) / (perp1.x2 - perp1.x1); float line_c = perp1.y1 - line_a * perp1.x1; + //y = b x + d float line_b = (perp2.y2 - perp2.y1) / (perp2.x2 - perp2.x1); - float line_d = perp2.y1 - line_b * perp2.x1; - + float line_d = perp2.y1 - line_b * perp2.x1; + intersectX = (line_d - line_c) / (line_a - line_b); intersectY = line_a * intersectX + line_c; }