diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libdraw/rectclip.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libdraw/rectclip.c')
| -rw-r--r-- | libdraw/rectclip.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libdraw/rectclip.c b/libdraw/rectclip.c new file mode 100644 index 00000000..740c7c4b --- /dev/null +++ b/libdraw/rectclip.c @@ -0,0 +1,24 @@ +#include "lib9.h" +#include "draw.h" + +int +rectclip(Rectangle *rp, Rectangle b) /* first by reference, second by value */ +{ + Rectangle *bp = &b; + /* + * Expand rectXrect() in line for speed + */ + if((rp->min.x<bp->max.x && bp->min.x<rp->max.x && + rp->min.y<bp->max.y && bp->min.y<rp->max.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; +} |
