home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User 10
/
AU_CD10.iso
/
Archived
/
Updates
/
Flash
/
writeflash
/
!MakeFlash
/
c
/
bbox
< prev
next >
Wrap
Text File
|
2000-04-16
|
954b
|
42 lines
#include <stdio.h>
#include "proto.h"
#include "bbox.h"
int bbox_init(RECT *rect, int *context) {
*context = 0;
return 0;
}
int bbox_add_point(RECT *rect, int *context, S32 x, S32 y, S32 radius) {
if (*context) {
if (x-radius < rect->minx) rect->minx = x-radius;
if (x+radius > rect->maxx) rect->maxx = x+radius;
if (y-radius < rect->miny) rect->miny = y-radius;
if (y+radius > rect->maxy) rect->maxy = y+radius;
} else {
rect->minx = rect->maxx = x;
rect->miny = rect->maxy = y;
*context = 1;
}
return 0;
}
int bbox_add_bbox(RECT *rect, int *context, RECT *bbox) {
if (bbox_add_point(rect, context, bbox->minx, bbox->miny, 0)) return 1;
if (bbox_add_point(rect, context, bbox->maxx, bbox->miny, 0)) return 1;
if (bbox_add_point(rect, context, bbox->minx, bbox->maxy, 0)) return 1;
if (bbox_add_point(rect, context, bbox->maxx, bbox->maxy, 0)) return 1;
return 0;
}