home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
utility
/
gemfut15
/
aesutrc3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-26
|
2KB
|
65 lines
/**************************************************************************
*
* AESFAST PD utilties.
*
* Rectangle utilities 2...
* rc_union
*************************************************************************/
#include <gemfast.h>
/*-------------------------------------------------------------------------
* rc_union - Compute union of 2 GRECT rectangles.
* Does not return anything, since by definition the two
* rectangles will have common area.
*
* (Note that this code is virtually identical to rc_intersect, except
* the direction of the comparison operators is reversed.)
*-----------------------------------------------------------------------*/
void
rc_union(prect1, prect2)
register GRECT *prect1;
register GRECT *prect2;
{
register int w1, w2;
int lx, rx;
int ty, by;
/* calc right-side x as the greater x of the two rectangles */
w1 = prect1->g_x + prect2->g_w;
w2 = prect2->g_x + prect2->g_w;
rx = (w1 > w2) ? w1 : w2;
/* calc bottom y as the greater y of the two rectanlges */
w1 = prect1->g_y + prect1->g_h;
w2 = prect2->g_y + prect2->g_h;
by = (w1 > w2) ? w1 : w2;
/* calc left-side x as the lesser x of the two rectangles */
w1 = prect1->g_x;
w2 = prect2->g_x;
lx = (w1 < w2) ? w1 : w2;
/* calc top y as the lesser y of the two rectangles */
w1 = prect1->g_y;
w2 = prect2->g_y;
ty = (w1 < w2) ? w1 : w2;
/* store the calculated rectangle (converting back to GRECT-type w/h) */
prect2->g_x = lx;
prect2->g_y = ty;
prect2->g_w = rx - lx;
prect2->g_h = by - ty;
return;
}