svg 变换矩阵解析器
问题解释: 变换=“矩阵(cos(a),sin(a),-sin(a),cos(a),-x1cos(a)+ y1sin(a)+ x2,-x1sin(a)-y1cos(a)+ y2)" 可以参见7.4坐标系转换
待解决: 在我的工作中,我必须解析矩阵 示例:
<?xml version="1.0" encoding="utf-8"?><svg width="800" height="500" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:PerfectSVG="http://www.perfectsvg.com/PerfectSVG" xml:space="preserve">
<defs>
<symbol overflow="visible" id="symbol1" connectPoints="15 70 50 0 87 68">
<g>
<line x1="300" y1="200" x2="309" y2="200" transform="matrix(1,0,0,1,0,0)" />
<line x1="311" y1="200" x2="320" y2="200" transform="matrix(1,0,0,1,0,0)" />
<line x1="300" y1="200" x2="304.75" y2="207.75" transform="matrix(1,0,0,1,0,0)" />
<line x1="315.75" y1="207" x2="320" y2="200" transform="matrix(1,0,0,1,0,0)" />
<line x1="309.25" y1="197.5" x2="309.25" y2="202.25" transform="matrix(1,0,0,1,0,0)"/>
<line x1="311" y1="197.25" x2="311" y2="202.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="313.75" y1="205.5" x2="318" y2="208.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="302.75" y1="209.5" x2="307.25" y2="206" transform="matrix(1,0,0,1,0,0)"/>
<line x1="303.75" y1="211" x2="308.25" y2="207.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="306" y1="209.25" x2="310.25" y2="215.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="312.75" y1="207.25" x2="317.25" y2="210.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="310.25" y1="215.25" x2="314.5" y2="208.75" transform="matrix(1,0,0,1,0,0)"/>
</g>
</symbol></defs><use xlink:href="#symbol1" transform="matrix(3.774,-2.246,2.246,3.774,-1562.468,-12.947)" stroke="#000000" fill="#FFFFFF" id="use3" stroke-width="0.2276867"/></svg>
现在: 我想知道示例中的 In:transform="matrix(3.774,-2.246,2.246,3.774,-1562.468,-12.947)" out:(a:角度 x1,y1:原始坐标 x2,y2:新坐标)
谁能给点建议或者一些参考资料
tks。
problem explain:
transform = "matrix(cos(a), sin(a), -sin(a), cos(a), -x1cos(a)+y1sin(a)+x2, -x1sin(a)-y1cos(a)+y2)"
can see 7.4 Coordinate system transformations
to be resolved:
in my work,i must resolve to parse matrix
example:
<?xml version="1.0" encoding="utf-8"?><svg width="800" height="500" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:PerfectSVG="http://www.perfectsvg.com/PerfectSVG" xml:space="preserve">
<defs>
<symbol overflow="visible" id="symbol1" connectPoints="15 70 50 0 87 68">
<g>
<line x1="300" y1="200" x2="309" y2="200" transform="matrix(1,0,0,1,0,0)" />
<line x1="311" y1="200" x2="320" y2="200" transform="matrix(1,0,0,1,0,0)" />
<line x1="300" y1="200" x2="304.75" y2="207.75" transform="matrix(1,0,0,1,0,0)" />
<line x1="315.75" y1="207" x2="320" y2="200" transform="matrix(1,0,0,1,0,0)" />
<line x1="309.25" y1="197.5" x2="309.25" y2="202.25" transform="matrix(1,0,0,1,0,0)"/>
<line x1="311" y1="197.25" x2="311" y2="202.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="313.75" y1="205.5" x2="318" y2="208.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="302.75" y1="209.5" x2="307.25" y2="206" transform="matrix(1,0,0,1,0,0)"/>
<line x1="303.75" y1="211" x2="308.25" y2="207.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="306" y1="209.25" x2="310.25" y2="215.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="312.75" y1="207.25" x2="317.25" y2="210.5" transform="matrix(1,0,0,1,0,0)"/>
<line x1="310.25" y1="215.25" x2="314.5" y2="208.75" transform="matrix(1,0,0,1,0,0)"/>
</g>
</symbol></defs><use xlink:href="#symbol1" transform="matrix(3.774,-2.246,2.246,3.774,-1562.468,-12.947)" stroke="#000000" fill="#FFFFFF" id="use3" stroke-width="0.2276867"/></svg>
Now:
i want to know In:transform="matrix(3.774,-2.246,2.246,3.774,-1562.468,-12.947)" out:(a:angle x1,y1:The original coordinates x2,y2:New coordinates) from the example
who can give suggestions or Some reference materials
tks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅通过变换数据不可能得到旧的x/y和新的x/y。
您必须拥有这三个数据中的两个。
您可以使用 getBBox 方法获取外框,然后就可以获取框的点。
It's impossible to get old x/y and new x/y only by transform data.
You must have two of the three data.
You can use getBBox method to get the outer box, and then you can get the box's dots.