Raphael SVG VML Implement Multi Pivot Points for Rotation

Posted by Cody N on Stack Overflow See other posts from Stack Overflow or by Cody N
Published on 2011-01-13T23:50:11Z Indexed on 2011/01/13 23:53 UTC
Read the original article Hit count: 290

Over the last two days I've effectively figured out how NOT to rotate Raphael Elements.

Basically I am trying to implement a multiple pivot points on element to rotate it by mouse.

When a user enters rotation mode 5 pivots are created. One for each corner of the bounding box and one in the center of the box.

When the mouse is down and moving it is simple enough to rotate around the pivot using Raphael elements.rotate(degrees, x, y) and calculating the degrees based on the mouse positions and atan2 to the pivot point.

The problem arises after I've rotated the element, bbox, and the other pivots. There x,y position in the same only there viewport is different.

In an SVG enabled browser I can create new pivot points based on matrixTransformation and getCTM. However after creating the first set of new pivots, every rotation after the pivots get further away from the transformed bbox due to rounding errors.

rotate errors

The above is not even an option in IE since in is VML based and cannot account for transformation.

Is the only effective way to implement element rotation is by using rotate absolute or rotating around the center of the bounding box?

Is it possible at all the create multi pivot points for an object and update them after mouseup to remain in the corners and center of the transformed bbox?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about svg