HTML旋转做一个SVG变换矩阵围绕其中心
<rect id="red" style="fill: red;" height="100" width="20"></rect>
JS
var layer =
{
sizeReal : { "width": 20, "height": 100 }
, sizeScaled : { "width": 10, "height": 50 }
, position : { "x": 200, "y": 200 }
, scale : 0.5
, rotation : 0
, matrix : [ 1, 0, 0, 1, 0, 0 ]
};
// Not sure if its the cleanest way but it works it rotates itself arounds its center.
//
$("#red")[0].setAttribute('transform', 'translate(' + layer.position.x + ',' + layer.position.y +') rotate(' + layer.rotation +',' + (layer.sizeScaled.width/2) + ',' + (layer.sizeScaled.height/2) + ') scale(' + layer.scale + ',' + layer.scale +')')
现在我想只能用一个矩阵来这样做。我正在使用sylvester来增加矩阵。
我做了一个小提琴,使问题清晰:)
我想红色矩形的行为一样的绿色矩形。我究竟做错了什么?
因此,我会基本上具有施加到svg元素3点矩阵。或者mul()将3合并为1? – Baijs
mul将三者合为一体 - 它只是矩阵的乘法 –