Alex Rivera | Logout

JS SVG getCTM and setCTM?

Asked 2012-04-23T13:41:37.650
12

If I use getCTM() to get the current tranformation matrix, how do I use that object to set the matrix if I want to restore it at a later point (I know about save and restore but those refer to the canvas and not items)

I know I set the attribute:

var m = someitem.getCTM();
$(someitem).attr("transform", "matrix("+m.a+","+m.b+","+m.c+","+ m.d+","+m.e+","+m.f+")");

But that seems sort of a long way of doing it. I can't find a setCTM function of any such close function.

Developing for webkit if that makes a difference.

Thanks!

Edit
Report

1 Answer

7
var transform = ownerSVGElement.createSVGTransform()

transform.setMatrix(elem.getCTM())

someelement.transform.baseVal.initialize(transform)
answered 2012-04-23T17:57:05.837

Your Answer