1 #include "lib9.h" 2 #include "draw.h" 3 4 int rectclip(Rectangle * rp,Rectangle b)5rectclip(Rectangle *rp, Rectangle b) /* first by reference, second by value */ 6 { 7 Rectangle *bp = &b; 8 /* 9 * Expand rectXrect() in line for speed 10 */ 11 if((rp->min.x<bp->max.x && bp->min.x<rp->max.x && 12 rp->min.y<bp->max.y && bp->min.y<rp->max.y)==0) 13 return 0; 14 /* They must overlap */ 15 if(rp->min.x < bp->min.x) 16 rp->min.x = bp->min.x; 17 if(rp->min.y < bp->min.y) 18 rp->min.y = bp->min.y; 19 if(rp->max.x > bp->max.x) 20 rp->max.x = bp->max.x; 21 if(rp->max.y > bp->max.y) 22 rp->max.y = bp->max.y; 23 return 1; 24 } 25