问题
I have rotated an SVG path element by setting the attribute transform="rotate(45)"
Now how could i get the rotated SVG path points ?
When i checked the attribute "d" its still showing the original points [ unrotated ].
回答1:
if you get point through path.getPointAtLength(), than you need to apply the transformation of the path to result. You get the total transform by:
var t = path.getTransformToElement( path.ownerSVGElement );
var abspoint = path.getPointAtLength( 0.5 ).matrixTransform( t );
I have not testes this,but this might be the way...
That is good for some points on the path. If the whole list of path data should be converted to absolute, than raphael might be the fastest solution...
回答2:
There's no functionality in svg itself that provides that. Not in jQuery either AFAIK.
The javascript library Raphaël contains a utility method for what you want though, see Raphael.transformPath.
来源:https://stackoverflow.com/questions/13508803/how-to-get-transformed-rotated-svg-path-points