From 4421738bf519dcfc8d8263262e917feb2d80a985 Mon Sep 17 00:00:00 2001 From: richTrash21 Date: Sat, 6 Jul 2024 19:12:51 +0400 Subject: [PATCH 1/4] remove blend mode from FlxCamera.fill() --- flixel/FlxCamera.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flixel/FlxCamera.hx b/flixel/FlxCamera.hx index 9e7156cff8..2f41f1ba64 100644 --- a/flixel/FlxCamera.hx +++ b/flixel/FlxCamera.hx @@ -1703,8 +1703,11 @@ class FlxCamera extends FlxBasic if (FxAlpha == 0) return; - var targetGraphics:Graphics = (graphics == null) ? canvas.graphics : graphics; + final targetGraphics = (graphics == null) ? canvas.graphics : graphics; + #if (openfl > "8.7.0") + targetGraphics.overrideBlendMode(null); + #end targetGraphics.beginFill(Color, FxAlpha); // i'm drawing rect with these parameters to avoid light lines at the top and left of the camera, // which could appear while cameras fading From 149f74ac5cd0d01ab5d755e7b1b571f68dfbd0d4 Mon Sep 17 00:00:00 2001 From: richTrash21 Date: Sat, 6 Jul 2024 20:39:35 +0400 Subject: [PATCH 2/4] more readable FlxCamera.drawFX() --- flixel/FlxCamera.hx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/flixel/FlxCamera.hx b/flixel/FlxCamera.hx index 2f41f1ba64..c3261180ac 100644 --- a/flixel/FlxCamera.hx +++ b/flixel/FlxCamera.hx @@ -1545,6 +1545,8 @@ class FlxCamera extends FlxBasic return; _fxFlashColor = Color; + if (_fxFlashColor.alpha == 0) + _fxFlashColor.alpha = 0xff; if (Duration <= 0) Duration = 0.000001; _fxFlashDuration = Duration; @@ -1567,6 +1569,8 @@ class FlxCamera extends FlxBasic return; _fxFadeColor = Color; + if (_fxFadeColor.alpha == 0) + _fxFadeColor.alpha = 0xff; if (Duration <= 0) Duration = 0.000001; @@ -1722,35 +1726,40 @@ class FlxCamera extends FlxBasic @:allow(flixel.system.frontEnds.CameraFrontEnd) function drawFX():Void { + var fxColor:FlxColor; var alphaComponent:Float; // Draw the "flash" special effect onto the buffer if (_fxFlashAlpha > 0.0) { - alphaComponent = _fxFlashColor.alpha; + fxColor = _fxFlashColor; + alphaComponent = fxColor.alphaFloat * _fxFlashAlpha; if (FlxG.renderBlit) { - fill((Std.int(((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFlashAlpha) << 24) + (_fxFlashColor & 0x00ffffff)); + fxColor.alphaFloat = alphaComponent; + fill(fxColor); } else { - fill((_fxFlashColor & 0x00ffffff), true, ((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFlashAlpha / 255, canvas.graphics); + fill(fxColor.rgb, true, alphaComponent, canvas.graphics); } } // Draw the "fade" special effect onto the buffer if (_fxFadeAlpha > 0.0) { - alphaComponent = _fxFadeColor.alpha; + fxColor = _fxFadeColor; + alphaComponent = fxColor.alphaFloat * _fxFadeAlpha; if (FlxG.renderBlit) { - fill((Std.int(((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFadeAlpha) << 24) + (_fxFadeColor & 0x00ffffff)); + fxColor.alphaFloat = alphaComponent; + fill(fxColor); } else { - fill((_fxFadeColor & 0x00ffffff), true, ((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFadeAlpha / 255, canvas.graphics); + fill(fxColor.rgb, true, alphaComponent, canvas.graphics); } } } From a754a10a358940e9ae1069fba7ca8f95d5d34052 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Mon, 15 Jul 2024 10:48:22 -0400 Subject: [PATCH 3/4] revert alpha overrides --- flixel/FlxCamera.hx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/flixel/FlxCamera.hx b/flixel/FlxCamera.hx index c3261180ac..5d28f5b0c1 100644 --- a/flixel/FlxCamera.hx +++ b/flixel/FlxCamera.hx @@ -1545,8 +1545,6 @@ class FlxCamera extends FlxBasic return; _fxFlashColor = Color; - if (_fxFlashColor.alpha == 0) - _fxFlashColor.alpha = 0xff; if (Duration <= 0) Duration = 0.000001; _fxFlashDuration = Duration; @@ -1569,8 +1567,6 @@ class FlxCamera extends FlxBasic return; _fxFadeColor = Color; - if (_fxFadeColor.alpha == 0) - _fxFadeColor.alpha = 0xff; if (Duration <= 0) Duration = 0.000001; From c472a7a4308ce8251dddf2fce48abec4c3cad26c Mon Sep 17 00:00:00 2001 From: George FunBook Date: Mon, 15 Jul 2024 10:52:39 -0400 Subject: [PATCH 4/4] more cleanup --- flixel/FlxCamera.hx | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/flixel/FlxCamera.hx b/flixel/FlxCamera.hx index 5d28f5b0c1..25e327050d 100644 --- a/flixel/FlxCamera.hx +++ b/flixel/FlxCamera.hx @@ -1722,40 +1722,35 @@ class FlxCamera extends FlxBasic @:allow(flixel.system.frontEnds.CameraFrontEnd) function drawFX():Void { - var fxColor:FlxColor; - var alphaComponent:Float; - // Draw the "flash" special effect onto the buffer if (_fxFlashAlpha > 0.0) { - fxColor = _fxFlashColor; - alphaComponent = fxColor.alphaFloat * _fxFlashAlpha; - if (FlxG.renderBlit) { - fxColor.alphaFloat = alphaComponent; - fill(fxColor); + var color = _fxFlashColor; + color.alphaFloat *= _fxFlashAlpha; + fill(color); } else { - fill(fxColor.rgb, true, alphaComponent, canvas.graphics); + final alpha = color.alphaFloat * _fxFlashAlpha; + fill(_fxFlashColor.rgb, true, alpha, canvas.graphics); } } - + // Draw the "fade" special effect onto the buffer if (_fxFadeAlpha > 0.0) { - fxColor = _fxFadeColor; - alphaComponent = fxColor.alphaFloat * _fxFadeAlpha; - if (FlxG.renderBlit) { - fxColor.alphaFloat = alphaComponent; - fill(fxColor); + var color = _fxFadeColor; + color.alphaFloat *= _fxFadeAlpha; + fill(color); } else { - fill(fxColor.rgb, true, alphaComponent, canvas.graphics); + final alpha = _fxFadeColor.alphaFloat * _fxFadeAlpha; + fill(_fxFadeColor.rgb, true, alpha, canvas.graphics); } } }