Skip to content

Fix drawing dashed rectangle with two tuple coords - #10614

Open
radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:dash
Open

radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:dash

Conversation

@radarhere

@radarhere radarhere commented Nov 24, 2026 •

Copy link
Copy Markdown
Member
from PIL import Image, ImageDraw
im = Image.new("RGB", (1, 1))
draw = ImageDraw.Draw(im)

# [x, y, x1, y1] with dash passes
draw.rectangle([10, 10, 90, 90], dash=(10, 5))
# [(x, y), (x1, y1)] without dash passes
draw.rectangle([(10, 10), (70, 70)])

# [(x, y), (x1, y1)] with dash raises an error currently
draw.rectangle([(10, 10), (70, 70)], dash=(10, 5))
Traceback (most recent call last):
  File "dash.py", line 8, in <module>
    draw.rectangle([(10, 10), (70, 70)], dash=(10, 5))
  File "PIL/ImageDraw.py", line 423, in rectangle
    (xy[2], xy[1]),
     ~~^^^
IndexError: list index out of range

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant