问题
Possible Duplicate:
How to get the actual x/y position of an element in SVG with transformations and matrices
I need to get the x/y positions of an element that is written like this in SVG:
<image
y="-421.28461"
x="335.27295"
id="image2991"
xlink:href="file:///C:/Users/tom/Documents/t.jpg"
height="369"
width="360"
transform="matrix(0.22297057,0.97482518,-0.97482518,0.22297057,0,0)" />
Here x & y attributes are given but this not gives the image actual position. As much as i know in the
transform matrix [a,b,c,d,e,f] e & f gives the translated axis in the x and y respectively. But the
problem is that here both ( e & f ) are 0. Now i can i get the actual x any y for this image?
回答1:
Assuming,
x="335.27295"
y="-421.28461"
Given the transformation matrix
a b e
c d f
0 0 1
Having the values
0.22297057 0.97482518 0
-0.97482518 0.22297057 0
0 0 1
Knowing
- a, d are responsible for scaling x, y respectivly
- e, f are responsible for transforming x, y respectivly
You`ll eventually get
newX = x * a + e
newY = y * d + f
Or,
newX = 335.27295 * 0.22297057 + 0 = 74.75
newY = -421.28461 * 0.22297057 + 0 = -93.93
来源:https://stackoverflow.com/questions/11535621/how-we-get-x-and-y-from-the-transform-matrix