[gtk/matthiasc/lottie2: 38/40] Implement gsk_circle_contour_get_point




commit 6dec158b2753163316d9af70c66fc795b811054a
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 95a6737e24..788c9bd843 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -611,7 +611,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]