|
|
1.1 root 1: #include "jerq.h"
2:
3: #define c corner
4: #define o origin
5:
6: int rectXrect(r, s) Rectangle r, s;
7: {
8: return(r.o.x<s.c.x && s.o.x<r.c.x && r.o.y<s.c.y && s.o.y<r.c.y);
9: }
10:
11: int ptinrect(p, r) Point p; Rectangle r;
12: {
13: return(p.x>=r.o.x && p.x<r.c.x && p.y>=r.o.y && p.y<r.c.y);
14: }
15:
16: rectclip(rp, b) register Rectangle *rp; Rectangle b;
17: { register Rectangle *bp= &b;
18: /* Expand rectXrect() in line for speed */
19: if ((rp->o.x < bp->c.x && bp->o.x < rp->c.x &&
20: rp->o.y < bp->c.y && bp->o.y < rp->c.y)==0) return 0;
21: /* They must overlap */
22: if (rp->origin.x < bp->origin.x) rp->origin.x = bp->origin.x;
23: if (rp->origin.y < bp->origin.y) rp->origin.y = bp->origin.y;
24: if (rp->corner.x > bp->corner.x) rp->corner.x = bp->corner.x;
25: if (rp->corner.y > bp->corner.y) rp->corner.y = bp->corner.y;
26: return 1;
27: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.