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]