From da42279171c8a10864de7f1962986a782f379408 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 10 May 2020 11:56:22 +0100 Subject: [PATCH] LibGfx: Fix dotted lines with thickness > 1 If we just skip every second pixel, we still get a solid line if each "pixel" is wider than 1! Now we skip the same amount of pixels as the line is thick. --- Libraries/LibGfx/Painter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibGfx/Painter.cpp b/Libraries/LibGfx/Painter.cpp index 418e1d47f2..5387b3c707 100644 --- a/Libraries/LibGfx/Painter.cpp +++ b/Libraries/LibGfx/Painter.cpp @@ -990,7 +990,7 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thick int min_y = max(point1.y(), clip_rect.top()); int max_y = min(point2.y(), clip_rect.bottom()); if (dotted) { - for (int y = min_y; y <= max_y; y += 2) + for (int y = min_y; y <= max_y; y += thickness * 2) draw_pixel({ x, y }, color, thickness); } else { for (int y = min_y; y <= max_y; ++y) @@ -1013,7 +1013,7 @@ void Painter::draw_line(const Point& p1, const Point& p2, Color color, int thick int min_x = max(point1.x(), clip_rect.left()); int max_x = min(point2.x(), clip_rect.right()); if (dotted) { - for (int x = min_x; x <= max_x; x += 2) + for (int x = min_x; x <= max_x; x += thickness * 2) draw_pixel({ x, y }, color, thickness); } else { for (int x = min_x; x <= max_x; ++x)