Skip to content

drawPolygon()

Draw a polygon straight onto the display.

display.drawPolygon(xPoints, yPoints)

The xPoints and yPoints lists are parallel: the first corner is (xPoints[0], yPoints[0]), the next is (xPoints[1], yPoints[1]), and so on. This draws to the canvas and returns nothing, which is fast and best for shapes you will not change later. To keep a handle you can move or delete, create a Polygon and add() it instead. Erase these drawings with clearDrawing().

Parameters

display.drawPolygon(xPoints, yPoints, color=Color.BLACK, fill=False, thickness=1, rotation=0)
Parameter Type Default Description
xPoints list[int or float] required The horizontal positions of the corners, in pixels.
yPoints list[int or float] required The vertical positions of the corners, in pixels.
color Color Color.BLACK The color.
fill bool False Whether the polygon is filled in (True) or just an outline (False).
thickness int 1 The outline thickness, in pixels.
rotation int or float 0 How far to turn the polygon, in degrees, counter-clockwise.