From 9b020a9c6ff875c5f6511b50480f07beabb9a694 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 11 Aug 2010 17:30:43 +0100 Subject: split out bounding box computation Signed-off-by: Henrik Rydberg --- src/grail-gestures.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/grail-gestures.c') diff --git a/src/grail-gestures.c b/src/grail-gestures.c index f1e2093..33d848c 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c @@ -218,3 +218,27 @@ void gru_end(struct grail *ge, int gid, const struct move_model *m, prop, nprop); } +void gru_compute_bbox(struct grail_coord *min, struct grail_coord *max, + const struct touch_frame *frame) +{ + float x, y; + int i; + if (frame->nactive < 1) + return; + x = frame->active[0]->prop[TP_POS_X]; + y = frame->active[0]->prop[TP_POS_Y]; + min->x = max->x = x; + min->y = max->y = y; + for (i = 1; i < frame->nactive; i++) { + x = frame->active[i]->prop[TP_POS_X]; + y = frame->active[i]->prop[TP_POS_Y]; + if (x < min->x) + min->x = x; + if (y < min->y) + min->y = y; + if (x > max->x) + max->x = x; + if (y > max->y) + max->y = y; + } +} -- cgit v1.2.3