From ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 30 Sep 2003 17:47:42 +0000 Subject: Initial import. --- src/libdraw/rectclip.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/libdraw/rectclip.c (limited to 'src/libdraw/rectclip.c') diff --git a/src/libdraw/rectclip.c b/src/libdraw/rectclip.c new file mode 100644 index 00000000..2228628b --- /dev/null +++ b/src/libdraw/rectclip.c @@ -0,0 +1,25 @@ +#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; +} -- cgit v1.2.3