typedef struct { long x1, x2, y1, y2; } Rivl_Box;x1 and y1 define the upper left corner of the box, which is included in the box's area. x2 and y2 define the lower right corner of the box, which is not included in the box's area. Thus, the width and height of the box is given by x2-x1 and y2-y1 respectively, and an empty box is one in which x1>=x2 or y1>=y2.
These procedures, while not difficult to perform by hand, are used frequently enough to include in the external interface.
Rivl_BoxCreate returns a box defined by newx1, newy1, newx2, and newy2.
Rivl_BoxIntersect returns the intersection of box1 and box2. An empty box is returned if box1 and box2 do not overlap.
Rivl_BoxOffset shifts the x coordinates of box by tx and the y coordinates by ty.
Rivl_BoxPad pads the right and left sides of box by px and the top and bottom by py. If px is positive, the width increases; otherwise it decreases. If py is positive, the height increases; otherwise it decreases.
Rivl_BoxScale multiplies the x coordinates of box by sx and the y coordinates of box by sy.
Rivl_BoxEmpty returns 1 if box.x1 >= box.x2 or box.y1 >= box.y2, and returns 0 otherwise.
Rivl_BoxArea returns the width of box times its height.