Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.scene.Scene;
  3. import javafx.scene.canvas.GraphicsContext;
  4. import javafx.scene.canvas.Canvas;
  5. import javafx.scene.layout.BorderPane;
  6. import javafx.scene.paint.Color;
  7. import javafx.scene.shape.Line;
  8. import javafx.stage.Stage;
  9.  
  10. //Нарисовать простую сцену - домик, солнце
  11. public class Main extends Application {
  12.  
  13. private static final int BOARD_WIDTH = 800;
  14. private static final int BOARD_HEIGHT = 600;
  15.  
  16. @Override
  17. public void start(Stage primaryStage) throws Exception {
  18. primaryStage.setTitle("Picture");
  19. Canvas canvas = new Canvas();
  20. canvas.setWidth(BOARD_WIDTH);
  21. canvas.setHeight(BOARD_HEIGHT);
  22. BorderPane group = new BorderPane(canvas);
  23. Scene scene = new Scene(group);
  24. primaryStage.setScene(scene);
  25. primaryStage.show();
  26. GraphicsContext gc = canvas.getGraphicsContext2D();
  27. test(gc);
  28. }
  29.  
  30. public static void main(String[] args) {
  31. launch(args);
  32. }
  33.  
  34. private void test(GraphicsContext gc) {
  35. gc.setFill(Color.GREEN);
  36.  
  37. gc.setLineWidth(5);
  38. gc.fillRect(0, 450, 800, 150);
  39. gc.setFill(Color.ORANGE);
  40. int diameter = 70;
  41. gc.fillOval(650, 50, diameter, diameter);
  42.  
  43. gc.setStroke(Color.ORANGE);
  44. gc.setLineWidth(3);
  45. gc.strokeLine(725, 85, 755, 85);
  46. gc.strokeLine(645, 85, 605, 85);
  47. gc.strokeLine(685, 45, 685, 15);
  48. gc.strokeLine(685, 125, 685, 155);
  49. gc.strokeLine(655, 57, 630, 32);
  50. gc.strokeLine(715, 57, 740, 32);
  51. gc.strokeLine(655, 115, 630, 142);
  52. gc.strokeLine(715, 115, 745, 142);
  53. gc.setFill(Color.LIGHTPINK);
  54. gc.fillRect(50, 230, 320, 220);
  55. gc.setFill(Color.WHITE);
  56. gc.fillRect(100, 250, 70, 100);
  57. gc.setStroke(Color.BLACK);
  58. gc.setLineWidth(1);
  59. gc.strokeLine(135, 251, 135, 349);
  60. gc.strokeLine(100, 300, 170, 300);
  61. gc.setFill(Color.BROWN);
  62. gc.fillRect(270, 340, 70, 110);
  63. gc.fillPolygon(new double[]{320, 290, 290, 320}, new double[]{95, 95, 120, 120}, 4);
  64. gc.setFill(Color.BLUE);
  65. gc.fillPolygon(new double[]{30, 50, 370, 390, 350, 70}, new double[]{230, 230, 230, 230, 120, 120}, 6);
  66.  
  67. Line oxLine1 = new Line(0, 0, 400, 0);
  68.  
  69. oxLine1.setStrokeWidth(5);
  70. oxLine1.setStroke(Color.BLUE);
  71.  
  72. gc.setStroke(Color.BLACK);
  73. gc.setLineWidth(2);
  74. diameter = 35;
  75. gc.strokeOval(550, 331, diameter, diameter);
  76. diameter = 2;
  77. gc.strokeOval(558, 343, diameter, diameter);
  78. gc.strokeOval(575, 343, diameter, diameter);
  79. gc.strokeLine(567, 366, 567, 372);
  80.  
  81. gc.strokeLine(553, 430, 545, 452);
  82. gc.strokeLine(545, 452, 539, 458);
  83. gc.strokeLine(581, 430, 590, 452);
  84. gc.strokeLine(590, 452, 596, 459);
  85.  
  86. gc.strokeLine(542, 395, 535, 405);
  87. gc.strokeLine(535, 405, 530, 408);
  88. gc.strokeLine(535, 405, 537, 409);
  89. gc.strokeLine(535, 405, 533, 410);
  90.  
  91. gc.strokeLine(593, 395, 600, 405);
  92. gc.strokeLine(600, 405, 598, 410);
  93. gc.strokeLine(600, 405, 606, 410);
  94. gc.strokeLine(600, 405, 602, 410);
  95.  
  96. gc.setFill(Color.BLUE);
  97. 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);
  98. gc.setFill(Color.MAGENTA);
  99. gc.fillPolygon(new double[]{552, 542, 560, 567, 574, 592, 582}, new double[]{410, 430, 430, 417, 430, 430, 410}, 7);
  100. }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement