我正在使用 KineticJS 并尝试旋转组。当我第一次旋转时,偏移量是正确的,并且它以我想要的方式旋转。当我更改组内矩形的大小然后尝试旋转它回到以前中心点或偏移。任何人都可以帮忙!?代码:
**//selectedShape 在这种情况下是组内的矩形,当我
//调整这个矩形的大小然后尝试旋转组它会改变一点**
selectedShape.setPosition(0, 0);
var offsetX = selectedShape.getWidth() / 2;
var offsetY = selectedShape.getHeight() / 2;
group.setOffset(offsetX, offsetY);
if (isForRotate)
{
group.rotate(Math.PI / 4);
}
//旋转后重置锚点位置
topLeft.setPosition(selectedShape.attrs.x, selectedShape.attrs.y);
topRight.setPosition(Number(selectedShape.attrs.x) + Number(selectedShape.getWidth()), selectedShape.attrs.y);
bottomLeft.setPosition(selectedShape.attrs.x, Number(selectedShape.attrs.y) + Number(selectedShape.getHeight()));
bottomRight.setPosition(Number(selectedShape.attrs.x) + Number(selectedShape.getWidth()), Number(selectedShape.attrs.y) + Number(selectedShape.getHeight()));
![enter image description here][1]