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



commit c5a6c2642bd685e497d3b2e39ea7ee0e9ddb8b73
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 |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimpunifiedtransformationtool.c b/app/tools/gimpunifiedtransformationtool.c
index cda3cf8..c237504 100644
--- a/app/tools/gimpunifiedtransformationtool.c
+++ b/app/tools/gimpunifiedtransformationtool.c
@@ -786,6 +786,27 @@ gimp_unified_transformation_tool_motion (GimpTransformTool *transform_tool)
       }
     }
 
+  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;
+      }
+    }
+
   /* old code below */
 #if 0
   if (options->alternate)



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