I wonder if there is a possibility to perform a perspective rotation on a square in JavaFX. When I normally rotate it on the x-axis I just get a compressed square, however I wanted to simulate a real-life rotation with perspective. The result should look something like this
Of course depending on the degree. Is there any way to achieve this, best case where it is possible to specify a certain degree.
Here is what the code for the compression looks like:
public class HelloWorld extends Application {
@Override
public void start(Stage primaryStage) {
StackPane root = new StackPane();
Rectangle rectangle = new Rectangle();
rectangle.setWidth(500);
rectangle.setHeight(500);
rectangle.setRotationAxis(Rotate.X_AXIS);
rectangle.setRotate(50);
Scene scene = new Scene(root, 1000, 1000);
root.getChildren().addAll(rectangle);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}