mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
commit
3a34f44bcf
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import os.path
|
import os.path
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -265,6 +266,21 @@ def test_chord_too_fat() -> None:
|
||||||
assert_image_equal_tofile(im, "Tests/images/imagedraw_chord_too_fat.png")
|
assert_image_equal_tofile(im, "Tests/images/imagedraw_chord_too_fat.png")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("mode", ("RGB", "L"))
|
||||||
|
@pytest.mark.parametrize("xy", ((W / 2, H / 2), [W / 2, H / 2]))
|
||||||
|
def test_circle(mode: str, xy: Sequence[float]) -> None:
|
||||||
|
# Arrange
|
||||||
|
im = Image.new(mode, (W, H))
|
||||||
|
draw = ImageDraw.Draw(im)
|
||||||
|
expected = f"Tests/images/imagedraw_ellipse_{mode}.png"
|
||||||
|
|
||||||
|
# Act
|
||||||
|
draw.circle(xy, 25, fill="green", outline="blue")
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert_image_similar_tofile(im, expected, 1)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("RGB", "L"))
|
@pytest.mark.parametrize("mode", ("RGB", "L"))
|
||||||
@pytest.mark.parametrize("bbox", BBOX)
|
@pytest.mark.parametrize("bbox", BBOX)
|
||||||
def test_ellipse(mode: str, bbox: Coords) -> None:
|
def test_ellipse(mode: str, bbox: Coords) -> None:
|
||||||
|
|
|
@ -227,6 +227,18 @@ Methods
|
||||||
|
|
||||||
.. versionadded:: 5.3.0
|
.. versionadded:: 5.3.0
|
||||||
|
|
||||||
|
.. py:method:: ImageDraw.circle(xy, radius, fill=None, outline=None, width=1)
|
||||||
|
|
||||||
|
Draws a circle with a given radius centering on a point.
|
||||||
|
|
||||||
|
.. versionadded:: 10.4.0
|
||||||
|
|
||||||
|
:param xy: The point for the center of the circle, e.g. ``(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.
|
||||||
|
|
||||||
.. py:method:: ImageDraw.ellipse(xy, fill=None, outline=None, width=1)
|
.. py:method:: ImageDraw.ellipse(xy, fill=None, outline=None, width=1)
|
||||||
|
|
||||||
Draws an ellipse inside the given bounding box.
|
Draws an ellipse inside the given bounding box.
|
||||||
|
@ -240,19 +252,6 @@ 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.
|
|
||||||
|
|
||||||
.. versionadded:: 10.4.0
|
|
||||||
|
|
||||||
: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.
|
|
||||||
|
|
||||||
.. 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.
|
||||||
|
|
|
@ -45,9 +45,12 @@ TODO
|
||||||
API Additions
|
API Additions
|
||||||
=============
|
=============
|
||||||
|
|
||||||
Added PIL.ImageDraw.circle()
|
ImageDraw.circle
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
Given the circle center coordinate pair and a radius, plots a circle using PIL.ImageDraw.ellipse()
|
|
||||||
|
Added :py:meth:`~PIL.ImageDraw.ImageDraw.circle`. It provides the same functionality as
|
||||||
|
:py:meth:`~PIL.ImageDraw.ImageDraw.ellipse`, but instead of taking a bounding box, it
|
||||||
|
takes a center point and radius.
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
^^^^
|
^^^^
|
||||||
|
|
Loading…
Reference in New Issue
Block a user