mirror of
https://github.com/python-pillow/Pillow.git
synced 2026-01-12 19:46:26 +03:00
Fix joining rounded rectangle corners (#9384)
This commit is contained in:
commit
e2b87a0420
BIN
Tests/images/imagedraw_rounded_rectangle_radius.png
Normal file
BIN
Tests/images/imagedraw_rounded_rectangle_radius.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 456 B |
|
|
@ -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",
|
||||
[
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user