Added line width argument to ImageDraw polygon by radarhere · Pull Request #5694 · python-pillow/Pillow
Resolves #5689
If we just drew thicker lines when creating a polygon, then since the centre of the line is the edge, half of each line would be drawn outside the filled polygon.
This PR uses masking to trim the outer half.
Because the image might have any mode, and there are limited modes that can be used as a mask,
- I draw the filled polygon on a 1-bit image,
fill_im - I draw the outline of the polygon on a 1-bit image,
ink_im, which extends outside the filled polygon - I use
fill_imas a mask to trim the polygon outline to just the inner part, giving a 1-bitmask. - Then I create an image with the destination mode, draw the outline, and use
maskto paste only the inner part on the original image.