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

Improved connecting discontiguous corners #8659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Jan 3, 2025

Resolves #8616

#8620 was flawed, primarily because I didn't notice when updating the test image that the corners were no longer connected. Searching back through Pillow versions though, I don't actually think this ever worked as intended, and this was obscured by assert_image_similar_tofile(img, expected, 1).

So this PR serves as a rethinking of #5980, and changes to assert_image_equal_tofile(img, expected) to ensure that the result is actually correct.

Here is how discontiguous corners are now connected to the rest of the polygon.

  1. Check that the horizontal row being processed is the start or end of the edge in question, and that it's not a horizontal edge.
  2. Find another edge matching the same conditions. You will see I have abandoned considering whether the slope of the line is positive or negative.
  3. Check that the rounded co-ordinates of the end of the two edges match.
  4. Consider the pixels from either the next row (or if it is the last row of the current edge, the previous row)
  5. Check that the second edge actually continues into that other row, and didn't end first
  6. If the position of both edges in that other row are greater (or are both less) than the position in this row, then extend the pixels in this row to meet it.

@radarhere radarhere marked this pull request as draft January 3, 2025 01:44
@radarhere radarhere changed the title Restored ImageDraw check that it is the end of edges being connected Improved connecting discontiguous corners Jan 4, 2025
@radarhere radarhere marked this pull request as ready for review January 6, 2025 22:03
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.

ImageDraw.polygon produces the wrong image
1 participant