Skip to content

Commit

Permalink
Fixed joined corners for odd dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed May 10, 2023
1 parent 2a274a4 commit c68c508
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
Binary file added Tests/images/imagedraw_rounded_rectangle_x_odd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tests/images/imagedraw_rounded_rectangle_y_odd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Tests/test_imagedraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,9 @@ def test_rounded_rectangle_zero_radius(bbox):
"xy, suffix",
[
((20, 10, 80, 90), "x"),
((20, 10, 81, 90), "x_odd"),
((10, 20, 90, 80), "y"),
((10, 20, 90, 81), "y_odd"),
((20, 20, 80, 80), "both"),
],
)
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/ImageDraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ def rounded_rectangle(

full_x, full_y = False, False
if all(corners):
full_x = d >= x1 - x0
full_x = d >= x1 - x0 - 1
if full_x:
# The two left and two right corners are joined
d = x1 - x0
full_y = d >= y1 - y0
full_y = d >= y1 - y0 - 1
if full_y:
# The two top and two bottom corners are joined
d = y1 - y0
Expand Down

0 comments on commit c68c508

Please sign in to comment.