Skip to content

Polygon

Polygons are closed shapes, drawn using two parallel lists of x and y coordinates. Unlike a Polyline, the shape is closed (the last corner joins back to the first).

Creating a Polygon

You can create a Polygon using the following functions:

Polygon(xPoints, yPoints)
Polygon(xPoints, yPoints, color, fill, thickness, rotation, visibility)
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.
visibility int 100 How visible the polygon is, from 0 (invisible) to 100 (fully visible).

For example,

polygon = Polygon([312, 366, 510, 443], [244, 210, 312, 346])

Once created, you can add it to a Display using the Display's add() function.

Functions

Once a Polygon has been created, the following functions are available: