From 5695a2b54bd2b9f729b1b5264553f4e463f9fafe Mon Sep 17 00:00:00 2001 From: "Enzo Persillet (Tutez)" Date: Sat, 30 May 2026 01:17:49 +0200 Subject: [PATCH 1/3] Preserve lineGradientStyle in SWF shape exports (cherry picked from commit 954ed5ff38303f3a8a9c87ad83a4b4c2ccff8076) --- src/swf/exporters/AnimateLibraryExporter.hx | 27 +++++++++++++++++++ src/swf/exporters/ShapeCommandExporter.hx | 6 +++++ src/swf/exporters/animate/AnimateLibrary.hx | 9 +++++++ .../exporters/animate/AnimateShapeCommand.hx | 2 ++ .../exporters/animate/AnimateShapeSymbol.hx | 4 +++ src/swf/exporters/core/ShapeCommand.hx | 2 ++ src/swf/exporters/swflite/ShapeSymbol.hx | 3 +++ 7 files changed, 53 insertions(+) diff --git a/src/swf/exporters/AnimateLibraryExporter.hx b/src/swf/exporters/AnimateLibraryExporter.hx index 1a5e2ee..9e4e27f 100644 --- a/src/swf/exporters/AnimateLibraryExporter.hx +++ b/src/swf/exporters/AnimateLibraryExporter.hx @@ -613,6 +613,19 @@ class AnimateLibraryExporter ]); } + case LineGradientStyle(type, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + commands = commands.concat([ + SWFShapeCommandType.LINE_GRADIENT_STYLE, + type, + colors, + alphas, + ratios, + serializeMatrix(matrix), + spreadMethod, + interpolationMethod, + focalPointRatio + ]); + case BeginFill(color, alpha): commands = commands.concat([SWFShapeCommandType.BEGIN_FILL, color, alpha]); @@ -992,6 +1005,19 @@ class AnimateLibraryExporter ]); } + case LineGradientStyle(type, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + commands = commands.concat([ + SWFShapeCommandType.LINE_GRADIENT_STYLE, + type, + colors, + alphas, + ratios, + serializeMatrix(matrix), + spreadMethod, + interpolationMethod, + focalPointRatio + ]); + case BeginFill(color, alpha): commands = commands.concat([SWFShapeCommandType.BEGIN_FILL, color, alpha]); @@ -1541,6 +1567,7 @@ private #if (haxe_ver >= 4.0) enum #end abstract SWFShapeCommandType(Int) from I public var LINE_STYLE = 6; public var LINE_TO = 7; public var MOVE_TO = 8; + public var LINE_GRADIENT_STYLE = 9; } #if (haxe_ver < 4.0) @:enum #end diff --git a/src/swf/exporters/ShapeCommandExporter.hx b/src/swf/exporters/ShapeCommandExporter.hx index ff5129d..5dbe15f 100644 --- a/src/swf/exporters/ShapeCommandExporter.hx +++ b/src/swf/exporters/ShapeCommandExporter.hx @@ -69,6 +69,12 @@ class ShapeCommandExporter extends DefaultShapeExporter commands.push(LineStyle(thickness, color, alpha, pixelHinting, scaleMode, startCaps, /*endCaps,*/ joints, miterLimit)); } + override public function lineGradientStyle(type:GradientType, colors:Array, alphas:Array, ratios:Array, matrix:Matrix = null, + spreadMethod:SpreadMethod = null, interpolationMethod:InterpolationMethod = null, focalPointRatio:Float = 0):Void + { + commands.push(LineGradientStyle(type, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio)); + } + override public function moveTo(x:Float, y:Float):Void { commands.push(MoveTo(x, y)); diff --git a/src/swf/exporters/animate/AnimateLibrary.hx b/src/swf/exporters/animate/AnimateLibrary.hx index 9aed6ed..eec92ad 100644 --- a/src/swf/exporters/animate/AnimateLibrary.hx +++ b/src/swf/exporters/animate/AnimateLibrary.hx @@ -662,6 +662,10 @@ import openfl.filters.GlowFilter; commands.push(LineStyle(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8])); i += 9; + case LINE_GRADIENT_STYLE: + commands.push(LineGradientStyle(data[i + 1], data[i + 2], data[i + 3], data[i + 4], __parseMatrix(data[i + 5]), data[i + 6], + data[i + 7], data[i + 8])); + i += 9; case LINE_TO: commands.push(LineTo(__pixel(data[i + 1]), __pixel(data[i + 2]))); i += 3; @@ -719,6 +723,10 @@ import openfl.filters.GlowFilter; case LINE_STYLE: commands.push(LineStyle(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8])); i += 9; + case LINE_GRADIENT_STYLE: + commands.push(LineGradientStyle(data[i + 1], data[i + 2], data[i + 3], data[i + 4], __parseMatrix(data[i + 5]), data[i + 6], + data[i + 7], data[i + 8])); + i += 9; case LINE_TO: commands.push(LineTo(__pixel(data[i + 1]), __pixel(data[i + 2]))); i += 3; @@ -819,6 +827,7 @@ import openfl.filters.GlowFilter; public var LINE_STYLE = 6; public var LINE_TO = 7; public var MOVE_TO = 8; + public var LINE_GRADIENT_STYLE = 9; } #if (haxe_ver >= 4.0) enum #else @:enum #end abstract SWFSymbolType(Int) from Int to Int diff --git a/src/swf/exporters/animate/AnimateShapeCommand.hx b/src/swf/exporters/animate/AnimateShapeCommand.hx index 7a708b0..d768c6b 100644 --- a/src/swf/exporters/animate/AnimateShapeCommand.hx +++ b/src/swf/exporters/animate/AnimateShapeCommand.hx @@ -19,6 +19,8 @@ enum AnimateShapeCommand EndFill; LineStyle(thickness:Null, color:Null, alpha:Null, pixelHinting:Null, scaleMode:Null /*LineScaleMode*/, caps:Null /*CapsStyle*/, joints:Null /*JointStyle*/, miterLimit:Null); + LineGradientStyle(fillType:Null /*GradientType*/, colors:Array, alphas:Array, ratios:Array, matrix:Matrix, + spreadMethod:Null /*SpreadMethod*/, interpolationMethod:Null /*InterpolationMethod*/, focalPointRatio:Float); LineTo(x:Float, y:Float); MoveTo(x:Float, y:Float); } diff --git a/src/swf/exporters/animate/AnimateShapeSymbol.hx b/src/swf/exporters/animate/AnimateShapeSymbol.hx index 7f2d1c9..902aa97 100644 --- a/src/swf/exporters/animate/AnimateShapeSymbol.hx +++ b/src/swf/exporters/animate/AnimateShapeSymbol.hx @@ -83,6 +83,10 @@ class AnimateShapeSymbol extends AnimateSymbol graphics.lineStyle(); } + case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + graphics.lineGradientStyle(GradientType.fromInt(fillType), colors, alphas, ratios, matrix, SpreadMethod.fromInt(spreadMethod), + InterpolationMethod.fromInt(interpolationMethod), focalPointRatio); + case LineTo(x, y): graphics.lineTo(x, y); diff --git a/src/swf/exporters/core/ShapeCommand.hx b/src/swf/exporters/core/ShapeCommand.hx index 923e3f8..9c8c4d8 100644 --- a/src/swf/exporters/core/ShapeCommand.hx +++ b/src/swf/exporters/core/ShapeCommand.hx @@ -25,6 +25,8 @@ enum ShapeCommand EndFill; LineStyle(thickness:Null, color:Null, alpha:Null, pixelHinting:Null, scaleMode:LineScaleMode, caps:CapsStyle, joints:JointStyle, miterLimit:Null); + LineGradientStyle(fillType:GradientType, colors:Array, alphas:Array, ratios:Array, matrix:Matrix, spreadMethod:SpreadMethod, + interpolationMethod:InterpolationMethod, focalPointRatio:Float); LineTo(x:Float, y:Float); MoveTo(x:Float, y:Float); } diff --git a/src/swf/exporters/swflite/ShapeSymbol.hx b/src/swf/exporters/swflite/ShapeSymbol.hx index 7064232..55421ee 100644 --- a/src/swf/exporters/swflite/ShapeSymbol.hx +++ b/src/swf/exporters/swflite/ShapeSymbol.hx @@ -83,6 +83,9 @@ class ShapeSymbol extends SWFSymbol graphics.lineStyle(); } + case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + graphics.lineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio); + case LineTo(x, y): graphics.lineTo(x, y); From 0ae14ba0df7997c1f6978e4f8b43065bd5bdaf60 Mon Sep 17 00:00:00 2001 From: "Enzo Persillet (Tutez)" Date: Sat, 30 May 2026 01:44:55 +0200 Subject: [PATCH 2/3] Handle line gradients in SWF runtime shapes --- src/swf/runtime/MorphShape.hx | 3 +++ src/swf/runtime/Shape.hx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/swf/runtime/MorphShape.hx b/src/swf/runtime/MorphShape.hx index aab8d50..ee93f7e 100644 --- a/src/swf/runtime/MorphShape.hx +++ b/src/swf/runtime/MorphShape.hx @@ -69,6 +69,9 @@ class MorphShape extends openfl.display.Shape graphics.lineStyle(); } + case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + graphics.lineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio); + case LineTo(x, y): graphics.lineTo(x, y); diff --git a/src/swf/runtime/Shape.hx b/src/swf/runtime/Shape.hx index a8afa80..bf1770b 100644 --- a/src/swf/runtime/Shape.hx +++ b/src/swf/runtime/Shape.hx @@ -49,6 +49,9 @@ class Shape extends openfl.display.Shape graphics.lineStyle(); } + case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + graphics.lineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio); + case LineTo(x, y): graphics.lineTo(x, y); From 185453cfc6a15a82a7e76c4c59b923b2696153e3 Mon Sep 17 00:00:00 2001 From: "Enzo Persillet (Tutez)" Date: Sat, 30 May 2026 01:51:23 +0200 Subject: [PATCH 3/3] Fix Flash color typing for line gradients --- src/swf/exporters/animate/AnimateShapeSymbol.hx | 3 +++ src/swf/exporters/swflite/ShapeSymbol.hx | 3 +++ src/swf/runtime/MorphShape.hx | 3 +++ src/swf/runtime/Shape.hx | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/swf/exporters/animate/AnimateShapeSymbol.hx b/src/swf/exporters/animate/AnimateShapeSymbol.hx index 902aa97..3810522 100644 --- a/src/swf/exporters/animate/AnimateShapeSymbol.hx +++ b/src/swf/exporters/animate/AnimateShapeSymbol.hx @@ -84,6 +84,9 @@ class AnimateShapeSymbol extends AnimateSymbol } case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + #if flash + var colors:Array = cast colors; + #end graphics.lineGradientStyle(GradientType.fromInt(fillType), colors, alphas, ratios, matrix, SpreadMethod.fromInt(spreadMethod), InterpolationMethod.fromInt(interpolationMethod), focalPointRatio); diff --git a/src/swf/exporters/swflite/ShapeSymbol.hx b/src/swf/exporters/swflite/ShapeSymbol.hx index 55421ee..1cedcdb 100644 --- a/src/swf/exporters/swflite/ShapeSymbol.hx +++ b/src/swf/exporters/swflite/ShapeSymbol.hx @@ -84,6 +84,9 @@ class ShapeSymbol extends SWFSymbol } case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + #if flash + var colors:Array = cast colors; + #end graphics.lineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio); case LineTo(x, y): diff --git a/src/swf/runtime/MorphShape.hx b/src/swf/runtime/MorphShape.hx index ee93f7e..8cd4c0e 100644 --- a/src/swf/runtime/MorphShape.hx +++ b/src/swf/runtime/MorphShape.hx @@ -70,6 +70,9 @@ class MorphShape extends openfl.display.Shape } case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + #if flash + var colors:Array = cast colors; + #end graphics.lineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio); case LineTo(x, y): diff --git a/src/swf/runtime/Shape.hx b/src/swf/runtime/Shape.hx index bf1770b..680f9a5 100644 --- a/src/swf/runtime/Shape.hx +++ b/src/swf/runtime/Shape.hx @@ -50,6 +50,9 @@ class Shape extends openfl.display.Shape } case LineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio): + #if flash + var colors:Array = cast colors; + #end graphics.lineGradientStyle(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio); case LineTo(x, y):