[gtk/path-work-rebased: 41/123] path: Fix serialization for circles
- From: Matthias Clasen <matthiasc src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [gtk/path-work-rebased: 41/123] path: Fix serialization for circles
 
- Date: Thu,  7 Apr 2022 20:40:55 +0000 (UTC)
 
commit ab604445cf44dd37f83a755fcd78d9764891f712
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Nov 28 11:56:25 2020 -0500
    path: Fix serialization for circles
    
    The svg A can not do a full circle, since it is a two point
    parametrization - if the start and end point are the same,
    it draws nothing. So, use two arcs.
 gsk/gskpath.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index 0add21d537..b3a5d4a758 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -550,16 +550,21 @@ gsk_circle_contour_print (const GskContour *contour,
                           GString          *string)
 {
   const GskCircleContour *self = (const GskCircleContour *) contour;
+  float mid_angle = (self->end_angle - self->start_angle) / 2;
 
   g_string_append (string, "M ");
   _g_string_append_point (string, &GSK_CIRCLE_POINT_INIT (self, self->start_angle));
   g_string_append (string, " A ");
   _g_string_append_point (string, &GRAPHENE_POINT_INIT (self->radius, self->radius));
-  g_string_append_printf (string, " 0 %u %u ",
-                          fabs (self->start_angle - self->end_angle) > 180 ? 1 : 0,
+  g_string_append_printf (string, " 0 0 %u ",
+                          self->start_angle < self->end_angle ? 0 : 1);
+  _g_string_append_point (string, &GSK_CIRCLE_POINT_INIT (self, mid_angle));
+  g_string_append (string, " A ");
+  _g_string_append_point (string, &GRAPHENE_POINT_INIT (self->radius, self->radius));
+  g_string_append_printf (string, " 0 0 %u ",
                           self->start_angle < self->end_angle ? 0 : 1);
   _g_string_append_point (string, &GSK_CIRCLE_POINT_INIT (self, self->end_angle));
-  if (fabs (self->start_angle - self->end_angle >= 360))
+  if (fabs (self->start_angle - self->end_angle) >= 360)
     g_string_append (string, " z");
 }
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]