home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Archived / Updates / Flash / writeflash / !MakeFlash / c / bbox < prev    next >
Text File  |  2000-04-16  |  954b  |  42 lines

  1. #include <stdio.h>
  2.  
  3. #include "proto.h"
  4. #include "bbox.h"
  5.  
  6.  
  7.  
  8. int bbox_init(RECT *rect, int *context) {
  9.  
  10.   *context = 0;
  11.  
  12.   return 0;
  13. }
  14.  
  15.  
  16. int bbox_add_point(RECT *rect, int *context, S32 x, S32 y, S32 radius) {
  17.  
  18.   if (*context) {
  19.     if (x-radius < rect->minx)  rect->minx = x-radius;
  20.     if (x+radius > rect->maxx)  rect->maxx = x+radius;
  21.     if (y-radius < rect->miny)  rect->miny = y-radius;
  22.     if (y+radius > rect->maxy)  rect->maxy = y+radius;
  23.   } else {
  24.     rect->minx = rect->maxx = x;
  25.     rect->miny = rect->maxy = y;
  26.     *context = 1;
  27.   }
  28.  
  29.   return 0;
  30. }
  31.  
  32.  
  33. int bbox_add_bbox(RECT *rect, int *context, RECT *bbox) {
  34.  
  35.   if (bbox_add_point(rect, context, bbox->minx, bbox->miny, 0))      return 1;
  36.   if (bbox_add_point(rect, context, bbox->maxx, bbox->miny, 0))      return 1;
  37.   if (bbox_add_point(rect, context, bbox->minx, bbox->maxy, 0))      return 1;
  38.   if (bbox_add_point(rect, context, bbox->maxx, bbox->maxy, 0))      return 1;
  39.  
  40.   return 0;
  41. }
  42.