[dia] [path] Fix path splitting and work on arc conversion



commit 6de4fed1efceb2ae8b6ff18de355d2db36c628e3
Author: Hans Breuer <hans breuer org>
Date:   Sat Oct 27 21:52:33 2012 +0200

    [path] Fix path splitting and work on arc conversion
    
    the latter still not working completely.

 lib/diapathrenderer.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/lib/diapathrenderer.c b/lib/diapathrenderer.c
index 5488b31..ed8329b 100644
--- a/lib/diapathrenderer.c
+++ b/lib/diapathrenderer.c
@@ -77,7 +77,7 @@ dia_path_renderer_finalize (GObject *object)
     guint i;
    
     for (i = 0; i < self->pathes->len; ++i) {
-      GArray *path = g_ptr_array_index (self->pathes, self->pathes->len - 1);
+      GArray *path = g_ptr_array_index (self->pathes, i);
 
       g_array_free (path, TRUE);
     }
@@ -115,7 +115,8 @@ _get_current_path (DiaPathRenderer *self,
   }
 
   if (!self->pathes || new_path) {
-    self->pathes = g_ptr_array_new ();
+    if (!self->pathes)
+      self->pathes = g_ptr_array_new ();
     g_ptr_array_add (self->pathes, g_array_new (FALSE, FALSE, sizeof(BezPoint)));
   }
   path = g_ptr_array_index (self->pathes, self->pathes->len - 1);
@@ -346,8 +347,12 @@ _arc (DiaRenderer *self,
   real radius = sqrt(width * height) / 2.0;
   real ar1 = (M_PI / 180.0) * angle1;
   real ar2 = (M_PI / 180.0) * angle2;
-  int i, segs = 3;
-  real ars = - (ar2 - ar1) / segs;
+  int i, segs;
+  real ars;
+  
+  /* one segment for ever 90 degrees */
+  segs = (int)(fabs(ar2 - ar1) / (M_PI/2)) + 1;
+  ars = - (ar2 - ar1) / segs;
 
   /* move to start point */
   start.x = center->x + (width / 2.0)  * cos(ar1);  
@@ -359,6 +364,10 @@ _arc (DiaRenderer *self,
    */
   ar1 = - ar1;
   ar2 = - ar2;
+  while (ar1 < 0 || ar2 < 0) {
+    ar1 += 2 * M_PI;
+    ar2 += 2 * M_PI;
+  }
 
   if (stroke) {
     _path_append (path, &start);



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