From d2453250f1cdd42cf23d2abf2fd6ffb7caa3fa0e Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 15 Mar 2024 23:58:07 +1100 Subject: [PATCH] Fixed joined corners for rounded_rectangle() non-integer dimensions --- Tests/test_imagedraw.py | 2 ++ src/PIL/ImageDraw.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 274753c6cee..0a699e2ab6a 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -868,8 +868,10 @@ def test_rounded_rectangle_zero_radius(bbox: Coords) -> None: [ ((20, 10, 80, 90), "x"), ((20, 10, 81, 90), "x_odd"), + ((20, 10, 81.1, 90), "x_odd"), ((10, 20, 90, 80), "y"), ((10, 20, 90, 81), "y_odd"), + ((10, 20, 90, 81.1), "y_odd"), ((20, 20, 80, 80), "both"), ], ) diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index d4e000087c4..d3efe64865e 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -336,6 +336,10 @@ def rounded_rectangle( d = radius * 2 + x0 = round(x0) + y0 = round(y0) + x1 = round(x1) + y1 = round(y1) full_x, full_y = False, False if all(corners): full_x = d >= x1 - x0 - 1