#include #include #include int rectclip(Rectangle *rp, Rectangle b) /* first by reference, second by value */ { Rectangle *bp = &b; /* * Expand rectXrect() in line for speed */ if((rp->min.xmax.x && bp->min.xmax.x && rp->min.ymax.y && bp->min.ymax.y)==0) return 0; /* They must overlap */ if(rp->min.x < bp->min.x) rp->min.x = bp->min.x; if(rp->min.y < bp->min.y) rp->min.y = bp->min.y; if(rp->max.x > bp->max.x) rp->max.x = bp->max.x; if(rp->max.y > bp->max.y) rp->max.y = bp->max.y; return 1; }