Skip to content

Commit e2b87a0

Browse files
authored
Fix joining rounded rectangle corners (#9384)
2 parents 627d874 + 426ad83 commit e2b87a0

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed
456 Bytes
Loading

Tests/test_imagedraw.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,18 @@ def test_rounded_rectangle_joined_x_different_corners() -> None:
895895
)
896896

897897

898+
def test_rounded_rectangle_radius() -> None:
899+
# Arrange
900+
im = Image.new("RGB", (W, H))
901+
draw = ImageDraw.Draw(im, "RGB")
902+
903+
# Act
904+
draw.rounded_rectangle((25, 25, 75, 75), 24, fill="red", outline="green", width=5)
905+
906+
# Assert
907+
assert_image_equal_tofile(im, "Tests/images/imagedraw_rounded_rectangle_radius.png")
908+
909+
898910
@pytest.mark.parametrize(
899911
"xy, radius, type",
900912
[

src/PIL/ImageDraw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def draw_corners(pieslice: bool) -> None:
487487

488488
if full_x:
489489
self.draw.draw_rectangle((x0, y0 + r + 1, x1, y1 - r - 1), fill_ink, 1)
490-
elif x1 - r - 1 > x0 + r + 1:
490+
elif x1 - r - 1 >= x0 + r + 1:
491491
self.draw.draw_rectangle((x0 + r + 1, y0, x1 - r - 1, y1), fill_ink, 1)
492492
if not full_x and not full_y:
493493
left = [x0, y0, x0 + r, y1]

0 commit comments

Comments
 (0)