Connected discontiguous polygon corners #5980
Merged
+52
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #4347
The issue reports that for a particular polygon, the corners are not visually joined to the main shape.
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. If I adjust Pillow to just draw the intersections of the edges on each row, it is clearer what has happened - no point in any of the lines is wrong, the angles are just such that the corner doesn't connect to the rest of the shape visually.
When hitting such corners, this PR finds the two edges making up the corner, calculates where those edges intersected with the adjacent row, and then stretches out the corner to connect to it.
The test includes the polygon from the issue, and two variations I put together.

Here is the test image without this fix.