[gimp/soc-2012-unified-transformation: 14/21] transformtool: Make rotate op behave as spec



commit 3ede009c18dbf9e8908c2f5268bc71df8f439fd8
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Thu Jun 14 09:10:00 2012 +0200

    transformtool: Make rotate op behave as spec

 app/tools/gimpunifiedtransformationtool.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimpunifiedtransformationtool.c b/app/tools/gimpunifiedtransformationtool.c
index d688436..28bceaf 100644
--- a/app/tools/gimpunifiedtransformationtool.c
+++ b/app/tools/gimpunifiedtransformationtool.c
@@ -802,6 +802,28 @@ gimp_unified_transformation_tool_motion (GimpTransformTool *transform_tool)
       return;
     }
 
+  if (function == TRANSFORM_HANDLE_ROTATION)
+    {
+      GimpVector2 m = { .x = transform_tool->curx,   .y = transform_tool->cury };
+      GimpVector2 p = { .x = transform_tool->mousex, .y = transform_tool->mousey };
+      GimpVector2 c = { .x = ppivot_x,               .y = ppivot_y };
+      gdouble angle = calcangle(vectorsubtract(m, c), vectorsubtract(p, c));
+      if (constrain)
+        {
+          /* round to 15 degree multiple */
+          angle /= 2*G_PI/24.;
+          angle = round(angle);
+          angle *= 2*G_PI/24.;
+        }
+      for (i = 0; i < 4; i++) {
+        p.x = px[i]; p.y = py[i];
+        m = vectoradd(c, rotate2d(vectorsubtract(p, c), angle));
+        *x[i] = m.x;
+        *y[i] = m.y;
+      }
+      return;
+    }
+
   if (options->alternate)
     {
       gdouble *x0, *x1, *y0, *y1;



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