The function draw.polygon()
cannot accept the argument "width", for example line()
.
In addition, it line()
will take a sequence of points and draw a polyline.
Line endings will be ugly, but by drawing circles at the ends, you can make them beautiful!
The code below shows a beautiful thick red polygon.
![enter image description here](https://fooobar.com/undefined)
from PIL import Image, ImageDraw
points = (
(30, 40),
(120, 60),
(110, 90),
(20, 110),
(30, 40),
)
im = Image.new("RGB", (130, 120))
dr = ImageDraw.Draw(im)
dr.line(points, fill="red", width=9)
for point in points:
dr.ellipse((point[0] - 4, point[1] - 4, point[0] + 4, point[1] + 4), fill="red")
im.save("polygon.png")
source
share