summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-12-13 22:41:48 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-12-13 22:45:29 -0500
commite4f4f6a81075d8c7d89388174b9478c187c2d386 (patch)
treeaf9f0c3b0e81e9aa54036659c3bebfc7ad95bbba
parent7a2d99576e854db67d65678f8821210de8732673 (diff)
downloadgtk+-fix-winding.tar.gz
Fix winding number for circle contoursfix-winding
If its open, it isn't winding. And if its closed, its winding number depends on the direction.
-rw-r--r--gsk/gskcontour.c28
1 files 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;