how to get center of rotation?

Discuss SVG code, accessible via the XML Editor.
psvoboda

how to get center of rotation?

Postby psvoboda » Fri Oct 01, 2010 8:31 am

Can I somehow get the center of rotation for an object from the XML file, or by javascript / svg commands? I need to programmatically (by javascript) rotate object created in inkscape. To be able to rotate it correctly I need to specify pivot (center of rotation) eg.calling JS function obj.setAttribute( "transform","rotate(angle, x, y)"); I need to know the correct x and y for my object.

Anyone can help?

P.S.: I have tried to derive center of rotation from the bounding box center, but this method does not work for objects rotated and scaled/ translated.

User avatar
shawnhcorey
Posts: 149
Joined: Mon Jan 07, 2008 12:17 pm

Re: how to get center of rotation?

Postby shawnhcorey » Thu Oct 07, 2010 9:28 am

It's been awhile since I did anything like this but you have to translate the centre of the object to the origin (0,0), rotate it, then translate it back.


Return to “SVG / XML Code”