KonvaJS将变换矩阵应用于React.Shape

时间:2017-09-07 11:25:10

标签: transform konvajs

在SVG中给出以下rect。

<rect xmlns="http://www.w3.org/2000/svg" x="72.036" y="156.473" transform="matrix(0.1727 -0.985 0.985 0.1727 -83.7081 215.7814)" style="fill:none;stroke:#020202;stroke-width:0.5;stroke-miterlimit:10;" width="29.129" height="2.498"/>

在rect上面想要在KonvaJS中作为Konva.Rect进行相应的渲染 https://konvajs.github.io/api/Konva.Rect.html

基于矩阵的分解,应该应用以下内容: 翻译(-83.7081,215.781) 旋转(-80.0554125754873) 规模(1.0000251446838724)

据我所知,旋转,缩放和倾斜可以应用,但如何应用翻译值? 它们是应该添加到x和y还是添加到offsetX / offsetY?

或者有没有办法将Transform类应用于Rect?

谢谢。

1 个答案:

答案 0 :(得分:0)

您应该使用{x,y}属性。

  

或者有没有办法将Transform类应用于Rect?

不,公共API不允许这样做。