[gimp/metadata-browser] transformtool: Make shear op behave as spec, no frompivot



commit e04a84a13ef0f2f11da67c6e410f2ceb5929679a
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Fri Jun 15 10:54:02 2012 +0200

    transformtool: Make shear op behave as spec, no frompivot

 app/tools/gimpunifiedtransformtool.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index c5bde45..d1eb282 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -859,12 +859,43 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
       //TODO: scale through side
     }
 
+  /* shear */
   if (function == TRANSFORM_HANDLE_N_S ||
       function == TRANSFORM_HANDLE_E_S ||
       function == TRANSFORM_HANDLE_S_S ||
       function == TRANSFORM_HANDLE_W_S)
     {
-      //TODO: shear
+      gint left, right;
+
+      if (function == TRANSFORM_HANDLE_N_S) {
+        left = 1; right = 0;
+      } else if (function == TRANSFORM_HANDLE_W_S) {
+        left = 0; right = 2;
+      } else if (function == TRANSFORM_HANDLE_S_S) {
+        left = 2; right = 3;
+      } else if (function == TRANSFORM_HANDLE_E_S) {
+        left = 3; right = 1;
+      } else g_assert_not_reached ();
+
+      if (constrain)
+        {
+          /* restrict to movement along the side */
+          GimpVector2 lp = { .x = px[left],  .y = py[left] },
+                      rp = { .x = px[right], .y = py[right] },
+                      p =  { .x = dx,        .y = dy },
+                      side = vectorsubtract (rp, lp);
+
+          p = vectorproject (p, side);
+
+          dx = p.x;
+          dy = p.y;
+        }
+
+      *x[left] = px[left] + dx;
+      *y[left] = py[left] + dy;
+
+      *x[right] = px[right] + dx;
+      *y[right] = py[right] + dy;
     }
 
   /* perspective transform */



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