Skip to content

Commit

Permalink
Merge pull request #8304 from radarhere/rounded_rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Aug 15, 2024
2 parents b141424 + d5e3f6b commit 394e850
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Tests/test_imagedraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,27 @@ def test_rounded_rectangle_corners(
)


def test_rounded_rectangle_joined_x_different_corners() -> None:
# Arrange
im = Image.new("RGB", (W, H))
draw = ImageDraw.Draw(im, "RGBA")

# Act
draw.rounded_rectangle(
(20, 10, 80, 90),
30,
fill="red",
outline="green",
width=5,
corners=(True, False, False, False),
)

# Assert
assert_image_equal_tofile(
im, "Tests/images/imagedraw_rounded_rectangle_joined_x_different_corners.png"
)


@pytest.mark.parametrize(
"xy, radius, type",
[
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/ImageDraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def draw_corners(pieslice: bool) -> None:

if full_x:
self.draw.draw_rectangle((x0, y0 + r + 1, x1, y1 - r - 1), fill_ink, 1)
else:
elif x1 - r - 1 > x0 + r + 1:
self.draw.draw_rectangle((x0 + r + 1, y0, x1 - r - 1, y1), fill_ink, 1)
if not full_x and not full_y:
left = [x0, y0, x0 + r, y1]
Expand Down

0 comments on commit 394e850

Please sign in to comment.