Skip to content
Snippets Groups Projects
Select Git revision
  • b37c71b1351d502639ba20f973f3e98eb169665b
  • main default protected
  • correction_video
  • going_further
  • ImprovedMouseInteraction
  • final2023
  • template
  • ModifGUI
8 results

CellularAutomatonSimulationTest.java

Blame
  • Forked from YAGOUBI Rim / Game of life Template
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    App.java 1.37 KiB
    package shape;
    
    import javafx.application.Application;
    import javafx.geometry.Point2D;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.canvas.Canvas;
    import javafx.scene.canvas.GraphicsContext;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import shape.tp3.*;
    
    public class App extends Application {
    
        public static void main(String[] args) {
            launch(args);
        }
    
        @Override
        public void start(Stage primaryStage) {
            Group root = new Group();
            Canvas canvas = new Canvas(300, 300); 
            GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
    
            ShapeContainer shapeContainer = new ShapeContainer();
    
            Shape rect = new Rectangle(Color.GRAY, new Point2D(150, 150), new Point2D(250, 250));
            Shape decoratedRect = new BorderDecorator(new CenterDecorator(rect, 5), 5);
            shapeContainer.addShape(decoratedRect);
    
            Shape triangle = new Polygon(Color.GRAY,
                    new Point2D(100, 50),
                    new Point2D(150, 150),
                    new Point2D(50, 150));
            Shape decoratedTriangle = new BorderDecorator(new CenterDecorator(triangle, 5), 5);
            shapeContainer.addShape(decoratedTriangle);
    
            shapeContainer.draw(graphicsContext);
    
            root.getChildren().add(canvas);
            primaryStage.setScene(new Scene(root));
            primaryStage.show();
        }
    }