NAME

Rivl_Box, Rivl_BoxCreate, Rivl_BoxIntersect, Rivl_BoxOffset, Rivl_BoxPad, Rivl_BoxScale, Rivl_BoxEmpty, Rivl_BoxArea - procedures to manipulate rectangle structures

SYNOPSIS

#include <rivl.h>
Rivl_Box
Rivl_BoxCreate (newx1, newy1, newx2, newy2)
Rivl_Box
Rivl_BoxIntersect (box1, box2)
Rivl_Box
Rivl_BoxOffset (box, tx, ty)
Rivl_Box
Rivl_BoxPad (box, px, py)
Rivl_Box
Rivl_BoxScale (box, sx, sy)
int
Rivl_BoxEmpty (box)
unsigned long
Rivl_BoxArea (box)

ARGUMENTS

Rivl_Box box (in)
A box.
long newx1, newy1, newx2, newy2
Coordinates of the new box.
double sx, sy (in)
Factors to scale box by.
long tx, ty (in)
Factors to offset box by.
long dx, dy
Factors to pad box by.

DESCRIPTION

A box is a set of four coordinates, defined as

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.