Skip to content

Commit

Permalink
Fix in-air grime application causing pink instead of white in level i…
Browse files Browse the repository at this point in the history
…mages.
  • Loading branch information
PJB3005 committed Jan 31, 2022
1 parent 472da5d commit 5b922e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions Drizzle.Logic/MathHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Drizzle.Logic;

public static class MathHelper
{
public static void SatAdd(ref byte val, byte add)
{
val = SatAdd(val, add);
}

public static byte SatAdd(byte val, byte add)
{
var added = val + add;
if (added > byte.MaxValue)
return byte.MaxValue;

return (byte)added;
}
}
4 changes: 2 additions & 2 deletions Drizzle.Logic/Rendering/LevelRenderer.RenderColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ void RainbowifyPixel(Vector2i pxl)
if (!IsPixelInFinalImageRainbowed(pxl + (-1, 0)))
{
var currCol = finalImage.getpixel(pxl.X - 1, pxl.Y);
currCol.GreenByte += 4;
MathHelper.SatAdd(ref currCol.GreenByte, 4);
finalImage.setpixel(pxl.X - 1, pxl.Y, currCol);
}

if (!IsPixelInFinalImageRainbowed(pxl + (0, -1)))
{
var currCol = finalImage.getpixel(pxl.X, pxl.Y - 1);
currCol.GreenByte += 4;
MathHelper.SatAdd(ref currCol.GreenByte, 4);
finalImage.setpixel(pxl.X, pxl.Y - 1, currCol);
}

Expand Down

0 comments on commit 5b922e8

Please sign in to comment.