The class Polygon¶
The class Polygon represents a polygon as its topologically sorted sequence of vertices.
- class polygon.Polygon(color, vertices)¶
Class methods:
Attributes:
- color¶
the color of the polygon, an (R, G, B) tuple
Methods:
- add(p)¶
Adds the given
Pointto the polygon
- bounding_box()¶
To be implemented. Returns the bounding box of the polygon (
Rectangle)
- rasterization(mtx)¶
To be implemented. Returns a list of pixels
Pointcorresponding to the polygon’s rasterization with the given window-to -viewport transformations mtx
Operation
Result
pol[i]Returns the i-th vertex of the polygon the vectorial image
The class supports the functions
len,strand the comparison operator ==.
The class Polygon is implemented in the file polygon.py.
You can pass the tests of the following test files test-polygon.txt.