From 2b6728533b226e0cbaa8b7307307fcb84cd19355 Mon Sep 17 00:00:00 2001 From: tasn Date: Tue, 28 Jun 2011 02:10:31 +0000 Subject: [PATCH] Evas polygon: Hopefully this time really fix is_inside calculation. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@60743 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/canvas/evas_object_polygon.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/canvas/evas_object_polygon.c b/src/lib/canvas/evas_object_polygon.c index 4fe6030..b48ff31 100644 --- a/src/lib/canvas/evas_object_polygon.c +++ b/src/lib/canvas/evas_object_polygon.c @@ -501,8 +501,8 @@ evas_object_polygon_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y) if (!o->points) return 0; /* Adjust X and Y according to current geometry */ - x -= obj->cur.geometry.x; - y -= obj->cur.geometry.y; + x -= o->offset.x; + y -= o->offset.y; if (eina_list_count(o->points) == 1) { @@ -525,16 +525,16 @@ evas_object_polygon_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y) p_next = eina_list_data_get(o->points); } - /* This only works if this condition is true */ - if ((x != p_next->x) && (p->x != p_next->x)) + /* Make sure that we are directly below the edge, + * and that p->x != p_next->x */ + if (((p->x < p_next->x) && (p->x <= x) && (x < p_next->x)) || + ((p->x > p_next->x) && (p_next->x < x) && (x <= p->x))) { line_y = ((double) (p->y - p_next->y) / (double) (p->x - p_next->x)) * (x - p_next->x) + p_next->y; /* We crossed that edge if the line is directly above us */ - if ((line_y < y) && - (((p->x < p_next->x) && (p->x <= x) && (x <= p_next->x)) || - ((p->x > p_next->x) && (p_next->x <= x) && (x <= p->x)))) + if (line_y < y) num_edges++; } } -- 2.7.4