get image rotation position

Discussion about writing code for Inkscape.
gabdab
Posts: 3
Joined: Fri Jan 17, 2014 7:54 am

get image rotation position

Postby gabdab » Sat Jan 18, 2014 1:21 am

I would like to export to js a sort of skeletal animation made with inkscape.
Problem is how to extrapolate position and rotation from bounding box value .
I am able to find rotation from transform matrix .
I have some python code that doesn't work predictabily as for position of the image from bounding box value .

Code: Select all

import math
import sys

#rotation : math.degrees(math.atan2(m2,m0)

c = input('membro a della matrice: ')
s = input('membro c della matrice: ')

px = input('spostamento x: ')
py = input('spostamento y: ')

x = input(' x: ')
y = input(' y: ')

width = input(' w: ')
hwidth = width/2

height = input('h: ')
hheight = height/2

scale = input('scale: ')

x1 = x -px + hwidth
y1 = y -py  + hheight

x2 = 1/scale*(c * x1) + 1/scale*(s * y1)

print x2 + px - hwidth


x1 = x + px + hwidth
y1 = y + py  + hheight

y2 = 1/scale*(-s * x1) + 1/scale*(c * y1)

print y2 - py - hheight


Return to “Programming”