Order ImageDraw.rounded_rectangle() points#6956
Order ImageDraw.rounded_rectangle() points#6956Yay295 wants to merge 2 commits intopython-pillow:mainfrom
Conversation
|
Your concern applies not just to from PIL import Image, ImageDraw
xy = (10, 20, 190, 180)
im = Image.new("RGB", (200, 200))
draw = ImageDraw.Draw(im)
draw.rectangle(xy, fill="red", outline="green", width=5)from PIL import Image, ImageDraw
xy = (190, 20, 10, 180)
im = Image.new("RGB", (200, 200))
draw = ImageDraw.Draw(im)
draw.rectangle(xy, fill="red", outline="green", width=5)It also applies to But I'm unsure about automatically correcting user's mistakes like this. If we silently handle this bug, it might lead to other problems in the user's code when they don't realise that they have their co-ordinates the wrong way around. @hugovk any thoughts? |
|
I though it looked like Lines 104 to 106 in 38931c1 I hadn't noticed |
|
Thinking about what might cause points to be out of order:
I expect it's had this behaviour for a long time. We could update the docs, and/or raise a |
|
Ok, I've created PR #6978, to update the docs for |
|
#6978 has been merged instead. |


If the points given to
ImageDraw.rounded_rectangle()aren't in the correct order, the rounded rectangle won't be drawn correctly. This change orders the coordinates before they're used.Here's what the images from my new test look like without my change:



(10, 20, 190, 180)
(10, 180, 190, 20)
(190, 20, 10, 180)
(190, 180, 10, 20)