diff --git a/CHANGELOG.md b/CHANGELOG.md index 87babc7b7..ffe667cd2 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 clip join - can be enabled in Settings ### Changed - Full path inside bundle is displayed as SWF name instead simple name diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index f819cff40..2597c85f8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -775,6 +775,10 @@ public final class Configuration { @ConfigurationDefaultBoolean(true) @ConfigurationCategory("ui") public static ConfigurationItem allowDragAndDropInTagListTree = null; + + @ConfigurationDefaultBoolean(false) + @ConfigurationCategory("display") + public static ConfigurationItem allowMiterClipLinestyle = null; private enum OSId { WINDOWS, OSX, UNIX 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 723fd51d7..4c4c13b1a 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 @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.exporters.shape; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.ImageTagBufferedImage; import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; @@ -440,8 +441,9 @@ public class BitmapExporter extends ShapeExporterBase { if (joinStyle == BasicStroke.JOIN_MITER) { lineStroke = new BasicStroke((float) thickness, capStyle, joinStyle, miterLimit); - //This seems to be correct, but ridiculously slow :-( - //lineStroke = new MiterClipBasicStroke((BasicStroke) lineStroke); + if (Configuration.allowMiterClipLinestyle.get()) { + 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 da27ace21..3ffec29d3 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 @@ -45,12 +45,15 @@ public class MiterClipBasicStroke implements Stroke { public float y1; public float x2; public float y2; + + public int kind; - public Vector(float x1, float y1, float x2, float y2) { + public Vector(float x1, float y1, float x2, float y2, int kind) { this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; + this.kind = kind; } public float getLength() { @@ -71,7 +74,7 @@ public class MiterClipBasicStroke implements Stroke { } public Vector reverse() { - return new Vector(x2, y2, x1, y1); + return new Vector(x2, y2, x1, y1, kind); } public Vector transform(AffineTransform t) { @@ -81,7 +84,7 @@ public class MiterClipBasicStroke implements Stroke { Point2D toDest = new Point2D.Float(); t.transform(fromSrc, fromDest); t.transform(toSrc, toDest); - return new Vector((float) fromDest.getX(), (float) fromDest.getY(), (float) toDest.getX(), (float) toDest.getY()); + return new Vector((float) fromDest.getX(), (float) fromDest.getY(), (float) toDest.getX(), (float) toDest.getY(), kind); } public Vector parallel(float w) { @@ -92,7 +95,7 @@ public class MiterClipBasicStroke implements Stroke { float y3 = y1 + yd; float x4 = x2 + xd; float y4 = y2 + yd; - return new Vector(x3, y3, x4, y4); + return new Vector(x3, y3, x4, y4, kind); } } @@ -107,63 +110,52 @@ public class MiterClipBasicStroke implements Stroke { float points[] = new float[6]; Area area = new Area(stroke.createStrokedShape(p)); - AffineTransform t = new AffineTransform(); List vectors = new ArrayList<>(); - List offPath = new ArrayList<>(); - List moveTo = new ArrayList<>(); float x = 0; float y = 0; + + final int KIND_MOVETO = 2; + final int KIND_OFFPATH = 1; + final int KIND_NORMAL = 0; + while (!pi.isDone()) { type = pi.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: - vectors.add(new Vector(x, y, points[0], points[1])); - offPath.add(true); - moveTo.add(true); + vectors.add(new Vector(x, y, points[0], points[1], KIND_MOVETO)); x = points[0]; y = points[1]; break; case PathIterator.SEG_LINETO: - vectors.add(new Vector(x, y, points[0], points[1])); - offPath.add(false); - moveTo.add(false); + vectors.add(new Vector(x, y, points[0], points[1], KIND_NORMAL)); x = points[0]; y = points[1]; break; case PathIterator.SEG_CUBICTO: - vectors.add(new Vector(x, y, points[0], points[1])); - offPath.add(true); - moveTo.add(false); - vectors.add(new Vector(points[0], points[1], points[2], points[3])); - offPath.add(true); - moveTo.add(false); - vectors.add(new Vector(points[2], points[3], points[4], points[5])); - offPath.add(false); - moveTo.add(false); + vectors.add(new Vector(x, y, points[0], points[1], KIND_OFFPATH)); + vectors.add(new Vector(points[0], points[1], points[2], points[3], KIND_OFFPATH)); + vectors.add(new Vector(points[2], points[3], points[4], points[5], KIND_NORMAL)); x = points[4]; y = points[5]; break; case PathIterator.SEG_QUADTO: - vectors.add(new Vector(x, y, points[0], points[1])); - offPath.add(true); - moveTo.add(false); - vectors.add(new Vector(points[0], points[1], points[2], points[3])); - offPath.add(false); - moveTo.add(false); + vectors.add(new Vector(x, y, points[0], points[1], KIND_OFFPATH)); + vectors.add(new Vector(points[0], points[1], points[2], points[3], KIND_NORMAL)); x = points[2]; y = points[3]; break; } pi.next(); } - + + //FIXME - make this faster!!! for (int i = 0; i < vectors.size() - 1; i++) { - if (offPath.get(i) || moveTo.get(i + 1)) { + Vector u = vectors.get(i); + Vector v = vectors.get(i + 1); + if (u.kind == KIND_OFFPATH || v.kind == KIND_MOVETO) { 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; diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 501952519..59d5a7d0c 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -591,3 +591,6 @@ config.description.allowPlacingDefinesIntoSprites = Allows placing (moving/copyi config.name.allowDragAndDropInTagListTree = Allow drag and drop in tag list view config.description.allowDragAndDropInTagListTree = Allows moving / copying tags with drag and drop in the tree of tag list view. +config.name.allowMiterClipLinestyle = Allow miter clip line styles (SLOW) +config.description.allowMiterClipLinestyle = Allow using custom renderer which supports miter clip line styles, but is slow. + diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties index 8260c2ea4..c9991a988 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_cs.properties @@ -577,3 +577,6 @@ config.description.allowPlacingDefinesIntoSprites = Povol\u00ed umis\u0165ov\u00 config.name.allowDragAndDropInTagListTree = Povolit drag and drop v zobrazen\u00ed seznamu tag\u016f config.description.allowDragAndDropInTagListTree = Povol\u00ed p\u0159esouv\u00e1n\u00ed / kop\u00edrov\u00e1n\u00ed tag\u016f pomoc\u00ed drag and drop v stromu zobrazen\u00ed seznamu tag\u016f. + +config.name.allowMiterClipLinestyle = Povolit styl \u010d\u00e1ry miter clip (POMAL\u00c9) +config.description.allowMiterClipLinestyle = Povol\u00ed pou\u017e\u00edv\u00e1n\u00ed vlastn\u00edho vykreslov\u00e1n\u00ed kter\u00e9 podporuje \u010d\u00e1ry se stylem miter clip, ale je pomal\u00e9.