mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-30 18:53:28 +03:00
Add function and documentation to draw circle
This commit is contained in:
parent
8b14ed741a
commit
2c4a6e1179
|
@ -240,6 +240,19 @@ Methods
|
||||||
|
|
||||||
.. versionadded:: 5.3.0
|
.. versionadded:: 5.3.0
|
||||||
|
|
||||||
|
.. py:method:: ImageDraw.circle(xy, radius, fill=None, outline=None, width=1)
|
||||||
|
|
||||||
|
Draws a circle given the center coordinates and a radius.
|
||||||
|
|
||||||
|
:param xy: One point to define the circle center. Sequence:
|
||||||
|
``[x, y]``
|
||||||
|
:param radius: Radius of the circle
|
||||||
|
:param outline: Color to use for the outline.
|
||||||
|
:param fill: Color to use for the fill.
|
||||||
|
:param width: The line width, in pixels.
|
||||||
|
|
||||||
|
.. versionadded:: ?.?.?
|
||||||
|
|
||||||
.. py:method:: ImageDraw.line(xy, fill=None, width=0, joint=None)
|
.. py:method:: ImageDraw.line(xy, fill=None, width=0, joint=None)
|
||||||
|
|
||||||
Draws a line between the coordinates in the ``xy`` list.
|
Draws a line between the coordinates in the ``xy`` list.
|
||||||
|
|
|
@ -181,6 +181,15 @@ class ImageDraw:
|
||||||
if ink is not None and ink != fill and width != 0:
|
if ink is not None and ink != fill and width != 0:
|
||||||
self.draw.draw_ellipse(xy, ink, 0, width)
|
self.draw.draw_ellipse(xy, ink, 0, width)
|
||||||
|
|
||||||
|
def circle(self, xy: Coords, radius, fill=None, outline=None, width=1) -> None:
|
||||||
|
"""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)
|
||||||
|
if fill is not None:
|
||||||
|
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."""
|
||||||
ink = self._getink(fill)[0]
|
ink = self._getink(fill)[0]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user