[gimp/soc-2012-unified-transformation: 31/52] transformtool: Copy the corner scale non-aspect frompivot code to side scale



commit a0484030380ed8ae68fde50677add22a769bc715
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Sun Jul 29 21:27:21 2012 +0200

    transformtool: Copy the corner scale non-aspect frompivot code to side scale

 app/tools/gimpunifiedtransformtool.c |   42 +++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index 742e23a..57906c3 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -1083,11 +1083,6 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
           /* just move the side */
           tl = vectoradd (tl, p);
           tr = vectoradd (tr, p);
-
-        if (frompivot)
-          {
-            //TODO
-          }
         }
 
       *x[this_l] = tl.x;
@@ -1101,6 +1096,43 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
 
       *x[opp_r] = or.x;
       *y[opp_r] = or.y;
+
+      if (!keepaspect && frompivot)
+        {
+          //TODO don't duplicate this code from above
+          GimpMatrix3 transform_before, transform_after;
+          gint i;
+          gdouble comp_x, comp_y;
+          gimp_matrix3_identity (&transform_before);
+          gimp_matrix3_identity (&transform_after);
+          gimp_transform_matrix_perspective (&transform_before,
+                                             transform_tool->x1,
+                                             transform_tool->y1,
+                                             transform_tool->x2 - transform_tool->x1,
+                                             transform_tool->y2 - transform_tool->y1,
+                                             px[0], py[0],
+                                             px[1], py[1],
+                                             px[2], py[2],
+                                             px[3], py[3]);
+          gimp_transform_matrix_perspective (&transform_after,
+                                             transform_tool->x1,
+                                             transform_tool->y1,
+                                             transform_tool->x2 - transform_tool->x1,
+                                             transform_tool->y2 - transform_tool->y1,
+                                             *x[0], *y[0],
+                                             *x[1], *y[1],
+                                             *x[2], *y[2],
+                                             *x[3], *y[3]);
+          gimp_matrix3_invert(&transform_before);
+          GimpMatrix3 transform = transform_before;
+          gimp_matrix3_mult(&transform_after, &transform);
+          gimp_matrix3_transform_point(&transform, pivot.x, pivot.y, &comp_x, &comp_y);
+          for (i = 0; i < 4; i++)
+            {
+              *x[i] -= comp_x - pivot.x;
+              *y[i] -= comp_y - pivot.y;
+            }
+        }
     }
 
   /* shear */



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