1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.transform.Shear; import javafx.stage.Stage; public class ShearingExample extends Application { @Override public void start(Stage stage) { Polygon hexagon1 = new Polygon(); hexagon1.getPoints().addAll(new Double[]{ 200.0, 50.0, 400.0, 50.0, 450.0, 150.0, 400.0, 250.0, 200.0, 250.0, 150.0, 150.0, }); hexagon1.setFill(Color.BLUE); hexagon1.setStroke(Color.BLACK); Polygon hexagon2 = new Polygon(); hexagon2.getPoints().addAll(new Double[]{ 200.0, 50.0, 400.0, 50.0, 450.0, 150.0, 400.0, 250.0, 200.0, 250.0, 150.0, 150.0, }); hexagon2.setFill(Color.TRANSPARENT); hexagon2.setStroke(Color.BLACK); Shear shear = new Shear(); shear.setPivotX(200); shear.setPivotY(250); shear.setX(0.5); shear.setY(0.0); hexagon2.getTransforms().addAll(shear); Group root = new Group(hexagon1, hexagon2); Scene scene = new Scene(root, 600, 300); stage.setTitle("Shearing Example "); stage.setScene(scene); stage.show(); } public static void main(String args[]){ launch(args); } }
|