Connected discontiguous polygon corners by radarhere · Pull Request #5980 · python-pillow/Pillow

Resolves #4347

The issue reports that for a particular polygon, the corners are not visually joined to the main shape.

image

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.

points

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.
Screen Shot 2022-01-21 at 11 49 24 am

Here is the test image without this fix.

Screen Shot 2022-01-21 at 11 49 45 am