如何获得变形/旋转的SVG路径点 [英] How to get transformed / Rotated SVG path points

查看:164
本文介绍了如何获得变形/旋转的SVG路径点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过设置属性transform ="rotate(45)"旋转了SVG路径元素

I have rotated an SVG path element by setting the attribute transform="rotate(45)"

现在如何获得旋转的SVG路径点?

Now how could i get the rotated SVG path points ?

当我检查属性"d"时,它仍显示原始点[未旋转].

When i checked the attribute "d" its still showing the original points [ unrotated ].

推荐答案

如果通过path.getPointAtLength()获得了点,则需要将路径的转换应用于结果.您可以通过以下方式获得总变换:

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...

这篇关于如何获得变形/旋转的SVG路径点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆