antvis/G6

对嵌套的group进行矩阵旋转会导致节点消失 #4772

zzjjbbaa posted onGitHub

使用矩阵可以达到任意变换:

``` // 单个图形旋转 const shape = group.addShape.... const shapeMatrix = shape.getMatrix(); if (!shapeMatrix) shapeMatrix =[1, 0, 0, 1, 0, 0, 0, 0, 1]; shapeMatrix = transform(shapeMatrix, [ ['t', -center[0], -center[1]], // 先平移到旋转中心 ['r', Math.PI / 3], // 旋转 Math.PI / 3 ['t', center[0], center[1]], // 平移回来 ]); shape.setMatrix(shapeMatrix);

// 整个图形组旋转 const groupMatrix = group.getMatrix(); if(!groupMatrix) groupMatrix = [1, 0, 0, 1, 0, 0, 0, 0, 1]; groupMatrix = transform(shapeMatrix, [ ['t', -center[0], -center[1]], // 先平移到旋转中心 ['r', Math.PI / 3], // 旋转 Math.PI / 3 ['t', center[0], center[1]], // 平移回来 ]); group.setMatrix(groupMatrix);

Originally posted by @Yanyan-Wang in https://github.com/antvis/G6/issues/1789#issuecomment-658008052


先看看 groupMatrix 里面的值是否正确

posted by Yanyan-Wang over 1 year ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests