Simplify circle() by reusing ellipse()

This commit is contained in:
void4 2024-05-27 13:01:10 +02:00 committed by GitHub
parent 8d9a4dda98
commit 38e6913579
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,12 +183,8 @@ class ImageDraw:
def circle(self, xy: Coords, radius, fill=None, outline=None, width=1) -> None: def circle(self, xy: Coords, radius, fill=None, outline=None, width=1) -> None:
"""Draw a circle given center coordinates and a radius.""" """Draw a circle given center coordinates and a radius."""
ink, fill = self._getink(outline, fill)
ellipse_xy = (xy[0] - radius, xy[1] - radius, xy[0] + radius, xy[1] + radius) ellipse_xy = (xy[0] - radius, xy[1] - radius, xy[0] + radius, xy[1] + radius)
if fill is not None: self.ellipse(ellipse_xy, fill, outline, width)
self.draw.draw_ellipse(ellipse_xy, fill, 1)
if ink is not None and ink != fill and width != 0:
self.draw.draw_ellipse(ellipse_xy, ink, 0, width)
def line(self, xy: Coords, fill=None, width=0, joint=None) -> None: def line(self, xy: Coords, fill=None, width=0, joint=None) -> None:
"""Draw a line, or a connected sequence of line segments.""" """Draw a line, or a connected sequence of line segments."""