[gtk/matthiasc/lottie2] Implement gsk_circle_contour_get_point



commit 8fc757f03166f8234353c68aa3abc608a981bd9e
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 25 17:55:44 2020 -0500

    Implement gsk_circle_contour_get_point

 gsk/gskpath.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index caff9dc78d..ae9a6d8fd3 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -600,7 +600,25 @@ gsk_circle_contour_get_point (const GskContour *contour,
                               graphene_point_t *pos,
                               graphene_vec2_t  *tangent)
 {
-  g_warning ("FIXME");
+  const GskCircleContour *self = (const GskCircleContour *) contour;
+  float delta = self->end_angle - self->start_angle;
+  float length = self->radius * DEG_TO_RAD (delta);
+  float angle = self->start_angle + distance/length * delta;
+  graphene_point_t p;
+
+  p = GRAPHENE_POINT_INIT (self->center.x + cos (DEG_TO_RAD (angle)) * self->radius,
+                              self->center.y + sin (DEG_TO_RAD (angle)) * self->radius);
+
+  if (pos)
+    *pos = p;
+
+  if (tangent)
+    {
+      graphene_vec2_init (tangent,
+                          p.y - self->center.y,
+                          - p.x + self->center.x);
+      graphene_vec2_normalize (tangent, tangent);
+    }
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]