home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel Volume 2 #1
/
carousel.iso
/
mactosh
/
lang
/
dial_cde.hqx
/
rectutils.c
< prev
next >
Wrap
Text File
|
1988-09-06
|
716b
|
49 lines
/*
* rectangle utilities
*/
#include "rectutils.h"
/*
* make a rectangle from the two points. If the coordinates would
* produce an invalid rectangle, switch them so that the rect is
* always valid.
*/
void
RUMakeRect(p1,p2,r)
Point p1,p2;
Rect *r;
{
if (p1.h < p2.h) {
r->left = p1.h;
r->right = p2.h;
} else {
r->left = p2.h;
r->right = p1.h;
}
if (p1.v < p2.v) {
r->top = p1.v;
r->bottom = p2.v;
} else {
r->top = p2.v;
r->bottom = p1.v;
}
}
/*
* like makerect except takes a width/height value in the second
* point rather than an actual point.
*/
void
RUMakeDeltaRect(p1,d,r)
Point p1,d;
Rect *r;
{
Point p2;
p2.h = p1.h + d.h;
p2.v = p1.v + d.v;
RUMakeRect(p1,p2,r);
}