![]() |
![]() |
![]() |
---|---|---|
Point Objects | Coordinate Systems | Transformation Objects |
Rect objects, or rects for short, represent rectangular areas of the drawing whose edges are parallel to the coordinate axes. They are represented by four floats for the positions of the left, bottom, right and top edges. Rects are kept in a normalized state where the left coordinate a less than the right coordinate and the bottom coordinate less than the top coordinate.
The bounding rects and coord rects of the graphics objects are such rect objects.
Rect objects provide efficient methods for boolean operations (union and intersection of rects) and tests for overlapping rects and contained points.
There are two special rect objects: InfinityRect
and
EmptyRect
. InfinityRect
represents the entire 2D plane while
EmptyRect
is an empty rect. These objects behave in special ways:
both overlap every other rect, InfinityRect
contains all points
while EmptyRect
contains no point, and so on. The particular
coordinates of these objects are irrelevant.
Rect objects are immutable.
Note: these rect objects have nothing to do with the rectangle primitive (apart fom the fact that the rectangle primitive has a bounding box...).
Return a new Rect object with the coordinates left, bottom, right and top or the opposite corners llcorner and urcorner given as points objects. The rectangle is automatically normalized, so you can swap left/right or top/bottom or choose any opposite corners.
Return the smallest rect that contains all points in
sequence. sequence must be a sequence of PointSpecs. If sequence is empty return
EmptyRect
A rect object has four (read only) attributes:
left
bottom
right
top
The left, bottom, right and top coordinate of the rect as python
floats. For InfinityRect
and EmptyRect
these have no
real meaning.
A rect object has these methods (self refers to the rect whose method is called):
contains_point(PointSpec)
contains_point(x, y)
Return true, if the point given by PointSpec or x and y is inside of self, false otherwise.
For InfinityRect
this is always true, for EmptyRect
always false.
contains_rect(r)
Return true, if the rect