rectclip.c - sam - An updated version of the sam text editor.
 (HTM) git clone git://vernunftzentrum.de/sam.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       rectclip.c (693B)
       ---
            1 /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
            2 #include <u.h>
            3 #include <libg.h>
            4 
            5 int rectclip(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 }