I could not find much details on getTransformToElement method, and how to use it correctly.
From the spec
“Returns the transformation matrix
from the user coordinate system on the
current element (after application of
the ‘transform’ attribute, if any) to
the user coordinate system on
parameter element (after application
of its ‘transform’ attribute, if
any).”
Terminology like, SVG canvas, viewbox, viewport, user cordinate, screen cordinate (http://www.w3.org/TR/SVG/coords.html) etc make it hard to understand what exactly this interface is used for.
thanks,
bsr
It returns a Transformation Matrix, I wouldn’t worry too much about that other terminology for now. If you have some SVG like this:
You can then use
getTransformToElementlike this:At the end of that code m will be an object representing a matrix (there’s a bunch of methods too, but I’m ignoring them):
You can then use that matrix to apply the same transform as on
mytextrelative tomysvgto any other element as per the matrix multiplication from the SVG spec:As noted in the comment below this method is deprecated in favour of
getCTMin the upcoming SVG 2 standard.