G6
G6 copied to clipboard
节点内shape的旋转动画如何指定旋转中心?
- G6 Version:
- Platform:
- Mini Showcase(like screenshots):
- CodePen Link:
shapes[11].animate(
(ratio: any) => {
const matrix = G6.Util.mat3.create();
const toMatrix = G6.Util.transform(matrix, [['r', ratio * Math.PI * 2]]);
return {
matrix: toMatrix
};
},
{
repeat: true,
duration: 1000
}
);
用这种方式旋转图形,图形的旋转中心是节点的(0,0)坐标,在图形不在(0,0)坐标时如何自旋呀~
如果是官网上这个例子,https://g6.antv.vision/zh/examples/scatter/node,这样就是沿着左上角旋转:
const toMatrix = Util.transform(matrix,
[['t', width / 2, height / 2],
['r', ratio * Math.PI * 2],
['t', -width / 2, -height / 2]]);
总体思想就是先把需要旋转的物体的旋转中心移动到 (0, 0) 然后旋转,再移回去
谢谢谢谢~
帮了大忙,感谢!
[['t', width / 2, height / 2], ['r', ratio * Math.PI * 2], ['t', -width / 2, -height / 2]]
感谢大佬,折腾了半天。
感谢,管用,不过我是
[['t', -width / 2, -height / 2], ['r', ratio * Math.PI * 2], ['t', width / 2, height / 2]]