1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

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.
This commit is contained in:
Linus Groh 2020-05-10 11:56:22 +01:00 committed by Andreas Kling
parent eb43e2d544
commit da42279171

View file

@ -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)