.. py:module:: rectangle The class Rectangle =================== The class :py:class:`Rectangle` represents a rectangle of the 2D space through its center, width, height and color. .. py:class:: Rectangle(center, width, height, color) .. rubric:: Class methods: .. py:method:: from_dict(dic) returns a Rectangle from a :py:class:`dict` .. rubric:: Attributes: .. py:attribute:: color the color of the rectangle, an (R, G, B) tuple .. py:attribute:: center the center of the rectangle (:py:class:`Point`) .. py:attribute:: width the width of the rectangle (:py:class:`float`) .. py:attribute:: height the height of the rectangle (:py:class:`float`) .. rubric:: Methods: .. py:method:: to_dict() Returns a :py:class:`dict` representing the rectangle .. py:method:: vmin() Returns a point with the smallest coordinates of the rectangle :py:class:`Point` .. py:method:: vmax() Returns a Ppoint with the largest coordinates of the rectangle :py:class:`Point` .. py:method:: aspect_ratio() Returns the ratio width by height of the rectangle .. py:method:: viewport_transform(width, height) Returns a transformation matrix that represents the geometric transformation of rasterization of the rectangle into a viewport of the given width and height .. py:method:: fitting_window(asp) To be implemented. Given an aspect ratio it returns the smallest possible centered rectangle that encloses the rectangle but fits the aspect ratio. To do so, it adds margins at top and bottom or right and left to get the desired aspect ratio. .. py:method:: rasterization(mtx) To be implemented. Returns a list of pixels :py:class:`~point.Point` made of the pixels of the rectangle's rasterization with the given window-to -viewport transformations matrix mtx The class supports the method :py:class:`str` and the comparison operator `==`. The class :py:class:`Rectangle` is implemented in the file :download:`rectangle.py `. You can pass the tests of the following test files :download:`test-rectangle.txt `.