Skip to content

Commit

Permalink
Fix FlxCamera.fill() blending (#3217)
Browse files Browse the repository at this point in the history
* remove blend mode from FlxCamera.fill()

* more readable FlxCamera.drawFX()

* revert alpha overrides

* more cleanup

---------

Co-authored-by: George FunBook <[email protected]>
  • Loading branch information
richTrash21 and Geokureli committed Jul 15, 2024
1 parent 8b8d40c commit ac488bf
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1705,8 +1705,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
Expand All @@ -1721,35 +1724,35 @@ class FlxCamera extends FlxBasic
@:allow(flixel.system.frontEnds.CameraFrontEnd)
function drawFX():Void
{
var alphaComponent:Float;

// Draw the "flash" special effect onto the buffer
if (_fxFlashAlpha > 0.0)
{
alphaComponent = _fxFlashColor.alpha;

if (FlxG.renderBlit)
{
fill((Std.int(((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFlashAlpha) << 24) + (_fxFlashColor & 0x00ffffff));
var color = _fxFlashColor;
color.alphaFloat *= _fxFlashAlpha;
fill(color);
}
else
{
fill((_fxFlashColor & 0x00ffffff), true, ((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFlashAlpha / 255, 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)
{
alphaComponent = _fxFadeColor.alpha;

if (FlxG.renderBlit)
{
fill((Std.int(((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFadeAlpha) << 24) + (_fxFadeColor & 0x00ffffff));
var color = _fxFadeColor;
color.alphaFloat *= _fxFadeAlpha;
fill(color);
}
else
{
fill((_fxFadeColor & 0x00ffffff), true, ((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFadeAlpha / 255, canvas.graphics);
final alpha = _fxFadeColor.alphaFloat * _fxFadeAlpha;
fill(_fxFadeColor.rgb, true, alpha, canvas.graphics);
}
}
}
Expand Down

0 comments on commit ac488bf

Please sign in to comment.