I have input values of x, y coordinates in the following format:
[[1,1], [2,1], [2,2], [1,2], [0.5,1.5]]
I want to draw polygons, but I don\'t
Another way to draw a polygon is this:
import PIL.ImageDraw as ImageDraw
import PIL.Image as Image
image = Image.new("RGB", (640, 480))
draw = ImageDraw.Draw(image)
# points = ((1,1), (2,1), (2,2), (1,2), (0.5,1.5))
points = ((100, 100), (200, 100), (200, 200), (100, 200), (50, 150))
draw.polygon((points), fill=200)
image.show()
Note that you need to install the pillow library. Also, I scaled up your coordinates by the factor of 100 so that we can see the polygon on the 640 x 480 screen.
Hope this helps.