Fix joining rounded rectangle corners (#9384)

This commit is contained in:
Hugo van Kemenade 2026-01-12 12:21:06 +02:00 committed by GitHub
commit e2b87a0420
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

View File

@ -895,6 +895,18 @@ def test_rounded_rectangle_joined_x_different_corners() -> None:
)
def test_rounded_rectangle_radius() -> None:
# Arrange
im = Image.new("RGB", (W, H))
draw = ImageDraw.Draw(im, "RGB")
# Act
draw.rounded_rectangle((25, 25, 75, 75), 24, fill="red", outline="green", width=5)
# Assert
assert_image_equal_tofile(im, "Tests/images/imagedraw_rounded_rectangle_radius.png")
@pytest.mark.parametrize(
"xy, radius, type",
[

View File

@ -487,7 +487,7 @@ class ImageDraw:
if full_x:
self.draw.draw_rectangle((x0, y0 + r + 1, x1, y1 - r - 1), fill_ink, 1)
elif x1 - r - 1 > x0 + r + 1:
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]