Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.canvas.GraphicsContext;
- import javafx.scene.canvas.Canvas;
- import javafx.scene.layout.BorderPane;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Line;
- import javafx.stage.Stage;
- //Нарисовать простую сцену - домик, солнце
- public class Main extends Application {
- private static final int BOARD_WIDTH = 800;
- private static final int BOARD_HEIGHT = 600;
- @Override
- public void start(Stage primaryStage) throws Exception {
- primaryStage.setTitle("Picture");
- Canvas canvas = new Canvas();
- canvas.setWidth(BOARD_WIDTH);
- canvas.setHeight(BOARD_HEIGHT);
- BorderPane group = new BorderPane(canvas);
- Scene scene = new Scene(group);
- primaryStage.setScene(scene);
- primaryStage.show();
- GraphicsContext gc = canvas.getGraphicsContext2D();
- test(gc);
- }
- public static void main(String[] args) {
- launch(args);
- }
- private void test(GraphicsContext gc) {
- gc.setFill(Color.GREEN);
- gc.setLineWidth(5);
- gc.fillRect(0, 450, 800, 150);
- gc.setFill(Color.ORANGE);
- int diameter = 70;
- gc.fillOval(650, 50, diameter, diameter);
- gc.setStroke(Color.ORANGE);
- gc.setLineWidth(3);
- gc.strokeLine(725, 85, 755, 85);
- gc.strokeLine(645, 85, 605, 85);
- gc.strokeLine(685, 45, 685, 15);
- gc.strokeLine(685, 125, 685, 155);
- gc.strokeLine(655, 57, 630, 32);
- gc.strokeLine(715, 57, 740, 32);
- gc.strokeLine(655, 115, 630, 142);
- gc.strokeLine(715, 115, 745, 142);
- gc.setFill(Color.LIGHTPINK);
- gc.fillRect(50, 230, 320, 220);
- gc.setFill(Color.WHITE);
- gc.fillRect(100, 250, 70, 100);
- gc.setStroke(Color.BLACK);
- gc.setLineWidth(1);
- gc.strokeLine(135, 251, 135, 349);
- gc.strokeLine(100, 300, 170, 300);
- gc.setFill(Color.BROWN);
- gc.fillRect(270, 340, 70, 110);
- gc.fillPolygon(new double[]{320, 290, 290, 320}, new double[]{95, 95, 120, 120}, 4);
- gc.setFill(Color.BLUE);
- gc.fillPolygon(new double[]{30, 50, 370, 390, 350, 70}, new double[]{230, 230, 230, 230, 120, 120}, 6);
- Line oxLine1 = new Line(0, 0, 400, 0);
- oxLine1.setStrokeWidth(5);
- oxLine1.setStroke(Color.BLUE);
- gc.setStroke(Color.BLACK);
- gc.setLineWidth(2);
- diameter = 35;
- gc.strokeOval(550, 331, diameter, diameter);
- diameter = 2;
- gc.strokeOval(558, 343, diameter, diameter);
- gc.strokeOval(575, 343, diameter, diameter);
- gc.strokeLine(567, 366, 567, 372);
- gc.strokeLine(553, 430, 545, 452);
- gc.strokeLine(545, 452, 539, 458);
- gc.strokeLine(581, 430, 590, 452);
- gc.strokeLine(590, 452, 596, 459);
- gc.strokeLine(542, 395, 535, 405);
- gc.strokeLine(535, 405, 530, 408);
- gc.strokeLine(535, 405, 537, 409);
- gc.strokeLine(535, 405, 533, 410);
- gc.strokeLine(593, 395, 600, 405);
- gc.strokeLine(600, 405, 598, 410);
- gc.strokeLine(600, 405, 606, 410);
- gc.strokeLine(600, 405, 602, 410);
- gc.setFill(Color.BLUE);
- gc.fillPolygon(new double[]{567, 552, 536, 547, 555, 552, 582, 579, 587, 598, 582}, new double[]{372, 372, 392, 397, 387, 410, 410, 387, 397, 392, 372}, 11);
- gc.setFill(Color.MAGENTA);
- gc.fillPolygon(new double[]{552, 542, 560, 567, 574, 592, 582}, new double[]{410, 430, 430, 417, 430, 430, 410}, 7);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement