The class Rectangle¶
The class Rectangle represents a rectangle of the 2D space through its center, width, height and color.
- class rectangle.Rectangle(center, width, height, color)¶
Class methods:
Attributes:
- color¶
the color of the rectangle, an (R, G, B) tuple
- center¶
the center of the rectangle (
Point)
Methods:
- vmin()¶
Returns a point with the smallest coordinates of the rectangle
Point
- vmax()¶
Returns a Ppoint with the largest coordinates of the rectangle
Point
- aspect_ratio()¶
Returns the ratio width by height of the rectangle
- 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
- 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.
- rasterization(mtx)¶
To be implemented. Returns a list of pixels
Pointmade of the pixels of the rectangle’s rasterization with the given window-to -viewport transformations matrix mtx
The class supports the method
strand the comparison operator ==.
The class Rectangle is implemented in the file rectangle.py.
You can pass the tests of the following test files test-rectangle.txt.