Skip to content

Commit

Permalink
DrawLine fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMakesGames committed Feb 6, 2025
1 parent 7a78fc7 commit f24691f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Company>Ben Hendel-Doying</Company>
<Description>Some GraphicsManager extensions for PlayPlayMini.</Description>
<Copyright>2023-2024 Ben Hendel-Doying</Copyright>
<Version>5.1.0</Version>
<Version>5.1.1</Version>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageTags>monogame playplaymini graphics extensions animations text</PackageTags>
Expand Down
12 changes: 10 additions & 2 deletions BenMakesGames.PlayPlayMini.GraphicsExtensions/LineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public static void DrawLine(this GraphicsManager graphics, int x1, int y1, int x

if ((x1 != oldX && y1 != oldY) || i == longest)
{
graphics.DrawFilledRectangle(oldX, oldY, x1 - dx1 - oldX + 1, y1 - dy1 - oldY + 1, color);
var rectX = Math.Min(oldX, x1 - dx1);
var rectY = Math.Min(oldY, y1 - dy1);
var rectW = Math.Abs(x1 - dx1 - oldX) + 1;
var rectH = Math.Abs(y1 - dy1 - oldY) + 1;
graphics.DrawFilledRectangle(rectX, rectY, rectW, rectH, color);
oldX = x1;
oldY = y1;
}
Expand All @@ -79,7 +83,11 @@ public static void DrawLine(this GraphicsManager graphics, int x1, int y1, int x

if ((x1 != oldX && y1 != oldY) || i == longest)
{
graphics.DrawFilledRectangle(oldX, oldY, x1 - dx2 - oldX + 1, y1 - dy2 - oldY + 1, color);
var rectX = Math.Min(oldX, x1 - dx2);
var rectY = Math.Min(oldY, y1 - dy2);
var rectW = Math.Abs(x1 - dx2 - oldX) + 1;
var rectH = Math.Abs(y1 - dy2 - oldY) + 1;
graphics.DrawFilledRectangle(rectX, rectY, rectW, rectH, color);
oldX = x1;
oldY = y1;
}
Expand Down

0 comments on commit f24691f

Please sign in to comment.