Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageDraw.Draw.polygon output is sometimes discontiguous #4347

Closed
elfprince13 opened this issue Jan 8, 2020 · 1 comment · Fixed by #5980
Closed

ImageDraw.Draw.polygon output is sometimes discontiguous #4347

elfprince13 opened this issue Jan 8, 2020 · 1 comment · Fixed by #5980
Projects

Comments

@elfprince13
Copy link

elfprince13 commented Jan 8, 2020

What did you do?

I drew a filled quadrilateral.

What did you expect to happen?

The output would be a contiguous quadrilateral.

What actually happened?

The output was discontiguous.

What are your OS, Python and Pillow versions?

  • OS: macOS 10.14.6
  • Python: Python 3.7.4 (default, Jul 11 2019, 01:08:00) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
  • Pillow: 6.1.0
from PIL import Image, ImageDraw
img = Image.new("1", (128, 128))
coords = [(29.0, 74.0), (62.0, 57.0), (99.0, 54.0), (66.0, 71.0)]
drawer = ImageDraw.Draw(img)
drawer.polygon(coords,1,1)
img.show()

Screen Shot 2020-01-08 at 4 58 26 PM

@radarhere
Copy link
Member

The way Pillow draws this polygon is by plotting on each row where each of the edges intersect, and then going through row by row and drawing horizontal lines. Here's an image to help illustrate.

points

No point in any of the lines is out of place. The angles have just conspired to create your discontiguous image.

I have created PR #5980 to resolve this.

@radarhere radarhere moved this from New Issues to In progress in Pillow Feb 24, 2022
Pillow automation moved this from In progress to Closed Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

2 participants