[gimp] app: Fix direction in path stroking



commit 7609e3d8879f52916d2767c4b867be37187ee534
Author: Alexia Death <alexiadeath gmail com>
Date:   Thu Jul 8 20:31:03 2010 +0300

    app: Fix direction in path stroking

 app/paint/gimppaintcore-stroke.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/app/paint/gimppaintcore-stroke.c b/app/paint/gimppaintcore-stroke.c
index d746ac6..3d7fc6c 100644
--- a/app/paint/gimppaintcore-stroke.c
+++ b/app/paint/gimppaintcore-stroke.c
@@ -376,38 +376,37 @@ gimp_paint_core_stroke_emulate_dynamics (GimpCoords *coords,
         }
     }
 
-  if (length > 0)
+  if (length > 1)
     {
       gint i;
+      gdouble delta_x;
+      gdouble delta_y;
 
       /* Fill in direction */
-      for (i = 2; i < length; i++)
+      for (i = 1; i < length; i++)
         {
-          gdouble delta_x = coords[i - 1].x - coords[i].x;
-          gdouble delta_y = coords[i - 1].y - coords[i].y;
+          delta_x = coords[i - 1].x - coords[i].x;
+          delta_y = coords[i - 1].y - coords[i].y;
 
-          if (delta_x == 0)
+          if ((delta_x == 0) && (delta_y == 0))
             {
               coords[i].direction = coords[i - 1].direction;
             }
           else
             {
-              coords[i].direction = 1.0 - atan (delta_y / delta_x) / (2 * G_PI);
-              if (delta_x > 0.0)
-                coords[i].direction = coords[i].direction + 0.5;
+              coords[i].direction = atan (delta_y / delta_x) / (2 * G_PI);
+
+              if (coords[i].direction < 0)
+                coords[i].direction += 1.0;
+
+              coords[i].direction = 1.0 - coords[i].direction;
             }
 
-          /* This should avoid confusing the interpolator on sharp
-           * turns where the angle warps
-           */
-          if (fabs (coords[i].direction - coords[i - 1].direction) > 0.5)
-            coords[i].direction = coords[i].direction + 1.0;
         }
 
-      if (length > 2)
+      if (length > 1)
         {
-          coords[0].direction = coords[2].direction;
-          coords[1].direction = coords[2].direction;
+          coords[0].direction = coords[1].direction;
         }
     }
 }



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