如何获得像多边形使用konva这样的形状的中心点?我需要在形状的中心添加一些文本标签。
您可以使用shape.getClientRect()获取形状的边界客户矩形。
shape.getClientRect()
那么中心的绝对位置将是:
const box = shape.getClientRect(); const x = box.x + box.width / 2; const y = box.y + box.height / 2;