Get current rotation in degrees of group in snap.svg

1k views Asked by At

how do i get the current rotation in degrees of a element in snap.svg? I can set a tranform but i find no easy way of getting a value.

A typical group looks like this.

<g transform="matrix(0.5154,0.5154,-0.5154,0.5154,64.3512,5.239)"><text x="0" y="0" style="font-size: 12px;">Change text</text></g>
1

There are 1 answers

0
Ian On BEST ANSWER

You can access elements matrices via the transform() function (with no parameters).

That will provide localMatrix which is probably what you want (if there are no nested transforms or anything). Then there is a function split() which will show the different parts of the matrix.

Using your SVG code above, access would look like this.

var g = Snap('g');

var matrixObj = g.transform().localMatrix.split()

alert( matrixObj.rotate );

jsfiddle