LibGFX: Draw the ends of lines with non-standard thickness

Lines are drawn using squares the size of the thickness, so if the
length of the line was not a multiple of the thickness, the end of the
line was not drawn correctly.
This commit is contained in:
Gal Horowitz 2021-10-02 19:45:07 +03:00 committed by Andreas Kling
parent cd7473d1a3
commit aa180c821d
Notes: sideshowbarker 2024-07-18 03:12:08 +09:00

View file

@ -1739,6 +1739,7 @@ void Painter::draw_line(IntPoint const& a_p1, IntPoint const& a_p2, Color color,
} else {
for (int y = min_y; y <= max_y; y += thickness)
draw_physical_pixel({ x, y }, color, thickness);
draw_physical_pixel({ x, max_y }, color, thickness);
}
return;
}
@ -1773,6 +1774,7 @@ void Painter::draw_line(IntPoint const& a_p1, IntPoint const& a_p2, Color color,
} else {
for (int x = min_x; x <= max_x; x += thickness)
draw_physical_pixel({ x, y }, color, thickness);
draw_physical_pixel({ max_x, y }, color, thickness);
}
return;
}