.. py:module:: polygon The class Polygon ================= The class :py:class:`Polygon` represents a polygon as its topologically sorted sequence of vertices. .. py:class:: Polygon(color, vertices) .. rubric:: Class methods: .. py:method:: from_dict(dic) returns a Polygon from a :py:class:`dict` .. rubric:: Attributes: .. py:attribute:: color the color of the polygon, an (R, G, B) tuple .. rubric:: Methods: .. py:method:: to_dict() Returns a :py:class:`dict` .. py:method:: add(p) Adds the given :py:class:`Point` to the polygon .. py:method:: bounding_box() To be implemented. Returns the bounding box of the polygon (:py:class:`Rectangle`) .. py:method:: rasterization(mtx) To be implemented. Returns a list of pixels :py:class:`~point.Point` corresponding to the polygon's rasterization with the given window-to -viewport transformations mtx .. py:rubric:: Supported operations +--------------------------+-------------------------------------------------+ | Operation | Result | +==========================+=================================================+ | ``pol[i]`` | Returns the i-th vertex of the polygon | | | the vectorial image | +--------------------------+-------------------------------------------------+ The class supports the functions :py:class:`len`, :py:class:`str` and the comparison operator `==`. The class :py:class:`Polygon` is implemented in the file :download:`polygon.py `. You can pass the tests of the following test files :download:`test-polygon.txt `.