JavaFX Shear effect

Description

JavaFX Shear effect


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Shear;
import javafx.stage.Stage;

public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);//from  ww  w.ja  v  a  2  s  . com
  }

  @Override
  public void start(Stage stage) {
    Rectangle rect1 = new Rectangle(100, 50, Color.LIGHTGRAY);
    rect1.setStroke(Color.BLACK);

    Rectangle rect2 = new Rectangle(100, 50, Color.YELLOW);
    rect2.setStroke(Color.BLACK);

    Shear shear = new Shear(0.5, 0.5);
    rect2.getTransforms().addAll(shear);

    Pane root = new Pane(rect1, rect2);
    root.setPrefSize(200, 100);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Applying Transformations");
    stage.show();
  }
}



PreviousNext

Related