# Geometry submodule

The Geometry submodule provides a collection of functions for operating on points and rectangles. See the section on Coordinates, Points and Rectangles for a discussion of how these entities are defined.

## Point functions

Returns the point resulting from adding the coordinates of points p1 and p2.
sub_pt(p1, p2)
Returns the point resulting from subtracting the coordinates of point p2 from those of point p1.

## Rectangle functions

rect_sized(p, size)
Returns a rectangle of the specified size with p as its top left corner.
rect_left(r)
rect_top(r)
rect_right(r)
rect_bottom(r)
These functions return the left, top, right or bottom coordinate, respectively, of the given rectangle.
rect_width(r)
rect_height(r)
These functions return the width or height, respectively, of the given rectangle.
rect_topleft(r)
rect_botright(r)
These functions return the top left or bottom right point, respectively, of the given rectangle.
rect_size(r)
Returns the size of the given rectangle.
union_rect(r1, r2)
Returns the union of the rectangles r1 and r2, i.e. the smallest rectangle enclosing both r1 and r2.
sect_rect(r1, r2)
Returns the intersection of rectangles r1 and r2.
inset_rect(r, (dx, dy))
Returns the rectangle resulting from displacing the sides of the rectangle r inwards horizontally by dx and vertically by dy.
offset_rect(r, (dx, dy))
Returns the rectangle resulting from displacing the rectangle r horizontally by dx and vertically by dy.
empty_rect(r)
Returns true if r is an empty rectangle.
pt_in_rect(p, r)
Returns true if the point p is in the rectangle r. A point is considered to be in a rectangle if the pixel immediately below and to the right of the point is enclosed by the rectangle.

rects_intersect(r1, r2)
Returns true if the intersection of rectangles r1 and r2 is nonempty.
---