[gimp/warp-wip-rebased: 26/56] gimpoperationwarp: memorize the last point to move the pixels accordingly



commit 6ce25851b54d4d1d9725139c4faa43dc551b9836
Author: Michael Muré <batolettre gmail com>
Date:   Sat Jun 18 18:32:27 2011 +0200

    gimpoperationwarp: memorize the last point to move the pixels accordingly

 app/gegl/gimpoperationwarp.c |   17 +++++++++++++++--
 app/gegl/gimpoperationwarp.h |    3 +++
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/app/gegl/gimpoperationwarp.c b/app/gegl/gimpoperationwarp.c
index a83376a..2b3d3bc 100644
--- a/app/gegl/gimpoperationwarp.c
+++ b/app/gegl/gimpoperationwarp.c
@@ -173,8 +173,12 @@ gimp_operation_warp_set_property (GObject      *object,
 static void
 gimp_operation_warp_prepare (GeglOperation *operation)
 {
+  GimpOperationWarp   *ow    = GIMP_OPERATION_WARP (operation);
+
   gegl_operation_set_format (operation, "input", babl_format_n (babl_type ("float"), 2));
   gegl_operation_set_format (operation, "output", babl_format_n (babl_type ("float"), 2));
+
+  ow->last_point_set = FALSE;
 }
 
 static gboolean
@@ -210,6 +214,13 @@ gimp_operation_warp_affect (const GeglPathItem *knot,
                                ow->size,
                                ow->size};
 
+  if (!ow->last_point_set)
+    {
+      ow->last_point = *(knot->point);
+      ow->last_point_set = TRUE;
+      return;
+    }
+
   format = babl_format_n (babl_type ("float"), 2);
 
   it = gegl_buffer_iterator_new (ow->buffer, &area, format, GEGL_BUFFER_READWRITE);
@@ -225,8 +236,8 @@ gimp_operation_warp_affect (const GeglPathItem *knot,
 
       while (n_pixels--)
         {
-          coords[0] += 2;
-          coords[1] += 2;
+          coords[0] += (ow->last_point.x - knot->point->x);
+          coords[1] += (ow->last_point.y - knot->point->y);
 
           coords += 2;
 
@@ -239,4 +250,6 @@ gimp_operation_warp_affect (const GeglPathItem *knot,
             }
         }
     }
+
+  ow->last_point = *(knot->point);
 }
\ No newline at end of file
diff --git a/app/gegl/gimpoperationwarp.h b/app/gegl/gimpoperationwarp.h
index 4d2fb95..e2e0260 100644
--- a/app/gegl/gimpoperationwarp.h
+++ b/app/gegl/gimpoperationwarp.h
@@ -42,6 +42,9 @@ struct _GimpOperationWarp
   gdouble              size;
   GeglPath            *stroke;
 
+  Point                last_point;
+  gboolean             last_point_set;
+
   GeglBuffer          *buffer; /* used to pass the temporary buffer to the function called by 
gegl_path_foreach */
 };
 


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