diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2009-06-02 13:01:45 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2009-06-02 13:01:45 +0000 |
commit | 30edb722902dff842b5b9544f9b43846b93adc92 (patch) | |
tree | ade17d9dc0ec2985a82a767134d2f22c354d181b /src/plot_util.c | |
parent | 3d5b21e1473dbdee6c3df66d9ba2a9d657f1b486 (diff) | |
download | libnsfb-30edb722902dff842b5b9544f9b43846b93adc92.tar.gz libnsfb-30edb722902dff842b5b9544f9b43846b93adc92.tar.bz2 |
add cursor support
svn path=/trunk/libnsfb/; revision=7687
Diffstat (limited to 'src/plot_util.c')
-rw-r--r-- | src/plot_util.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/plot_util.c b/src/plot_util.c index ae1f548..a126021 100644 --- a/src/plot_util.c +++ b/src/plot_util.c @@ -149,3 +149,49 @@ bool nsfb_plot_clip_line_ctx(nsfb_t *nsfb, nsfb_bbox_t * restrict line) return nsfb_plot_clip_line(&nsfb->clip, line); } +/* documented in libnsfb_plot_util.h */ +bool nsfb_plot_add_rect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2, nsfb_bbox_t *result) +{ + /* lower x coordinate */ + if (box1->x0 < box2->x0) + result->x0 = box1->x0; + else + result->x0 = box2->x0; + + /* lower y coordinate */ + if (box1->y0 < box2->y0) + result->y0 = box1->y0; + else + result->y0 = box2->y0; + + /* upper x coordinate */ + if (box1->x1 > box2->x1) + result->x1 = box1->x1; + else + result->x1 = box2->x1; + + /* upper y coordinate */ + if (box1->y1 > box2->y1) + result->y1 = box1->y1; + else + result->y1 = box2->y1; + + return true; +} + +bool nsfb_plot_bbox_intersect(const nsfb_bbox_t *box1, const nsfb_bbox_t *box2) +{ + if (box2->x1 < box1->x0) + return false; + + if (box2->y1 < box1->y0) + return false; + + if (box2->x0 > box1->x1) + return false; + + if (box2->y0 > box1->y1) + return false; + + return true; +} |