From: kramm Date: Wed, 26 Mar 2008 13:02:25 +0000 (+0000) Subject: new function gfxbbox_intersect X-Git-Tag: buttons-working~349 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=6ac96fe8d278883885cf1b885eade140ab76afe3;p=swftools.git new function gfxbbox_intersect --- diff --git a/lib/gfxtools.c b/lib/gfxtools.c index 30e72d8..486e285 100644 --- a/lib/gfxtools.c +++ b/lib/gfxtools.c @@ -615,6 +615,22 @@ gfxbbox_t gfxbbox_expand_to_point(gfxbbox_t box, gfxcoord_t x, gfxcoord_t y) return box; } +void gfxbbox_intersect(gfxbbox_t*box1, gfxbbox_t*box2) +{ + if(box2->xmin > box1->xmin) + box1->xmin = box2->xmin; + if(box2->ymin > box1->ymin) + box1->ymin = box2->ymin; + if(box2->xmax < box1->xmax) + box1->xmax = box2->xmax; + if(box2->ymax > box1->ymax) + box1->ymax = box2->ymax; + if(box1->xmin > box1->xmax) + box1->xmax = box1->xmin; + if(box1->ymin > box1->ymax) + box1->ymax = box1->ymin; +} + gfxbbox_t gfxline_getbbox(gfxline_t*line) { gfxcoord_t x=0,y=0; diff --git a/lib/gfxtools.h b/lib/gfxtools.h index d88b98f..8d6d397 100644 --- a/lib/gfxtools.h +++ b/lib/gfxtools.h @@ -68,6 +68,7 @@ void gfxdraw_conicTo(gfxdrawer_t*draw, double cx, double cy, double tox, double gfxbbox_t gfxline_getbbox(gfxline_t*line); gfxbbox_t gfxbbox_expand_to_point(gfxbbox_t box, gfxcoord_t x, gfxcoord_t y); +void gfxbbox_intersect(gfxbbox_t*box1, gfxbbox_t*box2); void gfxline_transform(gfxline_t*line, gfxmatrix_t*matrix);