Rectangle

Rectangle objects are created using the following functions.  Rectangles are drawn by specifying the top-left corner point (x1, y1) and the bottom-right corner point (x2, y2).

Function Description
Rectangle(x1, y1, x2, y2) Creates a Rectangle with top-left corner at x1, y1, and bottom-right corner at x2, y2.
Rectangle(x1, y1, x2, y2, color, fill, thickness) Creates a Rectangle with top-left corner at x1, y1, and bottom-right corner at x2, y2,  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 Rectangle 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
rec1.getX() Returns the x coordinate (in pixels).
rec1.getY() Returns the y coordinate (in pixels).
rec1.setX(x) Sets the x coordinate (in pixels).
rec1.setY(width) Sets the y coordinate (in pixels).
rec1.getPosition() Returns the position as an (x, y) tuple.
rec1.setPosition(x, y) Sets the position to x, y.
rec1.encloses(other) Returns True if rec1 encloses other (may be any Widget or Graphics object).
rec1.intersects(other) Returns True if rec1 intersects other (may be any Widget or Graphics object).