From f24691f9dddcb5a675d5febc487d50f7397821e0 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 6 Feb 2025 01:09:25 -0500 Subject: [PATCH] DrawLine fix --- ...MakesGames.PlayPlayMini.GraphicsExtensions.csproj | 2 +- .../LineExtensions.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/BenMakesGames.PlayPlayMini.GraphicsExtensions/BenMakesGames.PlayPlayMini.GraphicsExtensions.csproj b/BenMakesGames.PlayPlayMini.GraphicsExtensions/BenMakesGames.PlayPlayMini.GraphicsExtensions.csproj index 233cd95..83ecc41 100644 --- a/BenMakesGames.PlayPlayMini.GraphicsExtensions/BenMakesGames.PlayPlayMini.GraphicsExtensions.csproj +++ b/BenMakesGames.PlayPlayMini.GraphicsExtensions/BenMakesGames.PlayPlayMini.GraphicsExtensions.csproj @@ -5,7 +5,7 @@ Ben Hendel-Doying Some GraphicsManager extensions for PlayPlayMini. 2023-2024 Ben Hendel-Doying - 5.1.0 + 5.1.1 true monogame playplaymini graphics extensions animations text diff --git a/BenMakesGames.PlayPlayMini.GraphicsExtensions/LineExtensions.cs b/BenMakesGames.PlayPlayMini.GraphicsExtensions/LineExtensions.cs index bcf6e10..3606b90 100644 --- a/BenMakesGames.PlayPlayMini.GraphicsExtensions/LineExtensions.cs +++ b/BenMakesGames.PlayPlayMini.GraphicsExtensions/LineExtensions.cs @@ -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; } @@ -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; }