views:

62

answers:

4

I'm currently working on a WYSISYG editor that allows the user to move, resize and rotate shapes by directly manipulating them. The resizing seems to be fairly complex when the shape is rotated. I got this working for non-rotated shapes, but it will take some trigonometric calculations to resize shapes that are rotated. The registration point is always is the middle of the rectangle because this makes rotating a lot easier.

Before I start implementing this, I was wondering if anyone knew of any libraries or sample source code that does this, or could share some tips and tricks to calculate the transformations.

I have the following parameters:

  • rotation (in degrees)
  • width, height
  • x, y
  • mouseX, mouseY

I attached a screenshot of what I'm trying to accomplish and another one that has some lines drawn onto it that should allow me to deduct the trigonometric calculations. The cross is the cursor.

alt text

alt text

+2  A: 

You might look at flex-object-handles, in particular the more recent version 2.

Michael Brewer-Davis
+1  A: 

It's actually not that hard. Use the mouse coordinates (mouseX / mouseY)from the rotated display object and they will be transformed for you!

grapefrukt
+2  A: 

I recommend Transform Manager - http://www.greensock.com/transformmanageras3/

SparkyFlash
Thanks, this really looks interesting.
Christophe Herreman
A: 

Does anybody know if you can restrict flipping with http://www.greensock.com/transformmanageras3/ ?

thanx!

Ionel