order ImageDraw.rounded_rectangle() points

This commit is contained in:
Yay295 2023-02-16 08:51:21 -06:00
parent d48dca3dc4
commit 82a08d2032
2 changed files with 17 additions and 0 deletions

View File

@ -735,6 +735,22 @@ def test_rounded_rectangle(xy):
assert_image_equal_tofile(im, "Tests/images/imagedraw_rounded_rectangle.png")
@pytest.mark.parametrize(
"xy",
((10, 20, 190, 180), (190, 20, 10, 180), (190, 180, 10, 20), (10, 180, 190, 20)),
)
def test_rounded_rectangle_unordered_points(xy):
# Arrange
im = Image.new("RGB", (200, 200))
draw = ImageDraw.Draw(im)
# Act
draw.rounded_rectangle(xy, 30, fill="red", outline="green", width=5)
# Assert
assert_image_equal_tofile(im, "Tests/images/imagedraw_rounded_rectangle.png")
@pytest.mark.parametrize(
"xy, radius, type",
[

View File

@ -301,6 +301,7 @@ class ImageDraw:
(x0, y0), (x1, y1) = xy
else:
x0, y0, x1, y1 = xy
x0, y0, x1, y1 = min(x0, x1), min(y0, y1), max(x0, x1), max(y0, y1)
d = radius * 2