Do not draw line or arc if width is zero (#9589)

This commit is contained in:
Hugo van Kemenade 2026-05-12 19:55:18 +03:00 committed by GitHub
commit 954269051b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -175,7 +175,7 @@ class ImageDraw:
) -> None:
"""Draw an arc."""
ink, fill = self._getink(fill)
if ink is not None:
if ink is not None and width != 0:
self.draw.draw_arc(xy, start, end, ink, width)
def bitmap(
@ -235,12 +235,12 @@ class ImageDraw:
self,
xy: Coords,
fill: _Ink | None = None,
width: int = 0,
width: int = 1,
joint: str | None = None,
) -> None:
"""Draw a line, or a connected sequence of line segments."""
ink = self._getink(fill)[0]
if ink is not None:
if ink is not None and width != 0:
self.draw.draw_lines(xy, ink, width)
if joint == "curve" and width > 4:
points: Sequence[Sequence[float]]

View File

@ -3172,8 +3172,8 @@ _draw_lines(ImagingDrawObject *self, PyObject *args) {
PyObject *data;
int ink;
int width = 0;
if (!PyArg_ParseTuple(args, "Oi|i", &data, &ink, &width)) {
int width;
if (!PyArg_ParseTuple(args, "Oii", &data, &ink, &width)) {
return NULL;
}
@ -3182,7 +3182,7 @@ _draw_lines(ImagingDrawObject *self, PyObject *args) {
return NULL;
}
if (width <= 1) {
if (width == 1) {
double *p = NULL;
for (i = 0; i < n - 1; i++) {
p = &xy[i + i];