I'm working on an SVG map, which contains a lot of text
elements. The problem is, the old/source file has been generated years ago in Adobe Illustrator, which for some reason printed these elements as, e.g.:
<text transform="matrix(1 0 0 1 604.9754 765.0283)">4</text>
(First four arguments (1, 0, 0, 1) never change.)
What I want to achieve is to translate it into something like
<text x='123' y='456'>4</text>
I've already managed to collect all values needed using regex (text content and the two last transform arguments), but I have no idea what should I do next. I've also found out, that
The matrix( ) transform function specifies a transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix:
\begin{pmatrix} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{pmatrix}
which maps coordinates from a previous coordinate system into a new coordinate system by the following matrix equalities:
\begin{pmatrix} x_{\mathrm{newCoordSys}} \\ y_{\mathrm{newCoordSys}} \\ 1 \end{pmatrix} = \begin{pmatrix} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x_{\mathrm{prevCoordSys}} \\ y_{\mathrm{prevCoordSys}} \\ 1 \end{pmatrix} = \begin{pmatrix} a x_{\mathrm{prevCoordSys}} + c y_{\mathrm{prevCoordSys}} + e \\ b x_{\mathrm{prevCoordSys}} + d y_{\mathrm{prevCoordSys}} + f \\ 1 \end{pmatrix}
So my question is:
how can I translate these matrix transform values into X,Y coordinates?