我有 2 个矩形,坐标分别为 Rectangle1 (x = 100, y = 100, width = 200, height = 50) 和 Rectangle2 (x = 100, y = 200, width = 200, height = 50)。如何为它们设置仿射变换,以便它们围绕这些矩形的中心旋转(点 x = 200,y = 175)。例如,45 度:
我单独设置旋转
this.rotate.addListener((obs, old, fresh) -> {
Rotate groupRotate = new Rotate(rotate.get(),
this.x.getValue().doubleValue() + this.width.getValue().doubleValue() / 2 ,
this.y.getValue().doubleValue() + this.height.getValue().doubleValue() / 2);
for (VObject vObject : children ) {
vObject.getShape().getTransforms().clear();
vObject.getShape().getTransforms().add(groupRotate);
}
});
可以在不旋转坐标轴的情况下设置矩形的旋转吗?
最佳答案
编辑:关于移动旋转对象时保留轴的更新问题:将每个旋转对象添加到未旋转的容器中。现在移动这个容器而不是它的内容。
关于Javafx仿射变换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53497538/