[gtk/fix-winding] Fix winding number for circle contours
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-winding] Fix winding number for circle contours
- Date: Mon, 14 Dec 2020 03:46:24 +0000 (UTC)
commit e4f4f6a81075d8c7d89388174b9478c187c2d386
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 13 22:41:48 2020 -0500
Fix winding number for circle contours
If its open, it isn't winding. And if its closed,
its winding number depends on the direction.
gsk/gskcontour.c | 28 +++-------------------------
1 file changed, 3 insertions(+), 25 deletions(-)
---
diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c
index 33bbc72695..65f0ac1e4c 100644
--- a/gsk/gskcontour.c
+++ b/gsk/gskcontour.c
@@ -792,32 +792,10 @@ gsk_circle_contour_get_winding (const GskContour *contour,
if (fabs (self->start_angle - self->end_angle) >= 360)
{
- return -1;
- }
- else
- {
- /* Check if the point and the midpoint are on the same side
- * of the chord through start and end.
- */
- double mid_angle = (self->end_angle - self->start_angle) / 2;
- graphene_point_t start = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (self->start_angle)) *
self->radius,
- self->center.y + sin (DEG_TO_RAD (self->start_angle)) *
self->radius);
- graphene_point_t mid = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (mid_angle)) *
self->radius,
- self->center.y + sin (DEG_TO_RAD (mid_angle)) *
self->radius);
- graphene_point_t end = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (self->end_angle)) *
self->radius,
- self->center.y + sin (DEG_TO_RAD (self->end_angle)) *
self->radius);
-
- graphene_vec2_t n, m;
- float a, b;
-
- graphene_vec2_init (&n, start.y - end.y, end.x - start.x);
- graphene_vec2_init (&m, mid.x, mid.y);
- a = graphene_vec2_dot (&m, &n);
- graphene_vec2_init (&m, point->x, point->y);
- b = graphene_vec2_dot (&m, &n);
-
- if ((a < 0) != (b < 0))
+ if (self->end_angle > self->start_angle)
return -1;
+ else
+ return 1;
}
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]