[gtk/path-stroke] xxx: assorted fixes for special contours
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/path-stroke] xxx: assorted fixes for special contours
- Date: Sat, 26 Dec 2020 18:56:02 +0000 (UTC)
commit 0d3ee69afc1cf83b62aaa197500e7ecaec9022a3
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 26 13:51:24 2020 -0500
xxx: assorted fixes for special contours
Fix winding numbers, and strokes wrt to direction.
gsk/gskcontour.c | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
---
diff --git a/gsk/gskcontour.c b/gsk/gskcontour.c
index 51b67a2254..2d2dffb7ec 100644
--- a/gsk/gskcontour.c
+++ b/gsk/gskcontour.c
@@ -474,7 +474,12 @@ gsk_rect_contour_get_winding (const GskContour *contour,
graphene_rect_init (&rect, self->x, self->y, self->width, self->height);
if (graphene_rect_contains_point (&rect, point))
- return -1;
+ {
+ if (self->width < 0)
+ return 1;
+ else
+ return -1;
+ }
return 0;
}
@@ -854,32 +859,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->start_angle < self->end_angle)
return -1;
+ else
+ return 1;
}
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]