Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order ImageDraw.rounded_rectangle() points #6956

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Tests/test_imagedraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,22 @@ def test_rounded_rectangle_corners(top_left, top_right, bottom_right, bottom_lef
)


@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",
[
Expand Down
1 change: 1 addition & 0 deletions src/PIL/ImageDraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def rounded_rectangle(
(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)
if corners is None:
corners = (True, True, True, True)

Expand Down