Blob


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