Polygon

Polygon objects are created using the following functions.  Polygons are drawn by specifying their corners using two parallel lists of x and y coordinates.

Function Description
Polygon(xPoints, yPoints) Creates a Polygon with corners specified by the xPoints and yPoints lists.  The two lists are parallel, i.e., the first items correspond to the first polygon corner (x1, y1), the next items to the second corner (x2, y2), and so on.
Polygon(xPoints, yPoints, color, fill, thickness) Creates a Polygon with corners specified by the xPoints and yPoints lists,  color (e.g. Color.BLACK (default), Color.ORANGE or Color(255, 0, 255), using specific RGB values), fill (boolean – default is False), and thickness (default is 1 (pixel)).

Once a Polygon has been created, it may be added to a Display specifying where to place its top-left corner point.

Finally, you may use the following functions:

Function Description
poly1.getX() Returns the x coordinate (in pixels).
poly1.getY() Returns the y coordinate (in pixels).
poly1.setX(x) Sets the x coordinate (in pixels).
poly1.setY(width) Sets the y coordinate (in pixels).
poly1.getPosition() Returns the position as an (x, y) tuple.
poly1.setPosition(x, y) Sets the position to x, y.
poly1.encloses(other) Returns True if poly1 encloses other (may be any Widget or Graphics object).
poly1.intersects(other) Returns True if poly1 intersects other (may be any Widget or Graphics object).