Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. import javafx.animation.AnimationTimer;
  2. import javafx.application.Application;
  3. import javafx.stage.Stage;
  4. import javafx.scene.paint.*;
  5. import javafx.scene.canvas.*;
  6. import javafx.scene.shape.Ellipse;
  7.  
  8.  
  9.  
  10. public class truck extends Application {
  11.  
  12. @Override
  13. public void start(Stage stage) throws Exception {
  14. // set up window title and size
  15. GraphicsContext gc = JIGraphicsUtility.setUpGraphics(stage, "Truck", 400, 700);
  16. AnimationTimer timer = new AnimationTimer() {
  17. double x = 0;
  18.  
  19. @Override
  20. public void handle(long now) {
  21. gc.setFill(Color.PINK);
  22. gc.fillRect(0, 0, 700, 400);
  23. gc.setFill(Color.BLACK);
  24. gc.fillRect(10 + x, 100, 300, 200);
  25. gc.setFill(Color.BLUE);
  26. gc.fillRect(200 + x, 150, 110, 50);
  27. gc.setFill(Color.RED);
  28. gc.fillOval(80 + x, 270, 60, 60);
  29. gc.fillOval(200 + x, 270, 60, 60);
  30. x += 3;
  31. gc.setFill(Color.WHITE);
  32. gc.fillOval(570, 20, 50,50);
  33. gc.setFill(Color.WHITE);
  34. gc.fillOval(610, 20, 50,50);
  35. gc.setFill(Color.WHITE);
  36. gc.fillOval(650, 20, 50,50);
  37. gc.setFill(Color.GREEN);
  38. gc.fillOval(0, 320, 350,250 );
  39. gc.fillOval(130, 300, 400,350 );
  40. gc.fillOval(370, 360, 300,150 );
  41. gc.fillOval(500, 340, 300,220 );
  42. gc.setFill(Color.YELLOW);
  43. gc.fillOval(-50, -50, 100,100 );
  44. gc.setStroke( Color.YELLOW);
  45. gc.strokeLine ( 0, 0, 70, 10);
  46. gc.strokeLine ( 0, 0, 65, 20);
  47. gc.strokeLine ( 0, 0, 60, 30);
  48. gc.strokeLine ( 0, 0, 55, 40);
  49. gc.strokeLine ( 0, 0, 50, 50);
  50. gc.strokeLine ( 0, 0, 45, 60);
  51. gc.strokeLine ( 0, 0, 37, 65);
  52. gc.strokeLine ( 0, 0, 30, 70);
  53. gc.strokeLine ( 0, 0, 20, 72);
  54. gc.strokeLine ( 0, 0, 10, 75);
  55.  
  56. gc.setFill(Color.LIMEGREEN);
  57. gc.fillRect(200, 290, 5, 50);
  58. gc.setFill(Color.YELLOW);
  59. gc.fillOval(197, 277, 10, 7);
  60. gc.setFill(Color.PURPLE);
  61. gc.fillOval(200, 266, 6, 12);
  62. gc.fillOval(200, 283, 6, 12);
  63. gc.fillOval(186, 280, 12, 6);
  64. gc.fillOval(206, 280, 12, 6);
  65. gc.setFill(Color.YELLOW);
  66. gc.fillOval(197, 277, 10, 7);
  67.  
  68. gc.setFill(Color.LIMEGREEN);
  69. gc.fillRect(300, 270, 5, 50);
  70. gc.setFill(Color.PURPLE);
  71. gc.fillOval(300, 246, 6, 12);
  72. gc.fillOval(300, 263, 6, 12);
  73. gc.fillOval(286, 260, 12, 6);
  74. gc.fillOval(306, 260, 12, 6);
  75. gc.setFill(Color.YELLOW);
  76. gc.fillOval(297, 257, 10, 7);
  77.  
  78. gc.setFill(Color.LIMEGREEN);
  79. gc.fillRect(400, 260, 5, 55);
  80. gc.setFill(Color.PURPLE);
  81. gc.fillOval(400, 236, 6, 12);
  82. gc.fillOval(400, 253, 6, 12);
  83. gc.fillOval(386, 250, 12, 6);
  84. gc.fillOval(406, 250, 12, 6);
  85. gc.setFill(Color.YELLOW);
  86. gc.fillOval(397, 247, 10, 7);
  87.  
  88. gc.setFill(Color.LIMEGREEN);
  89. gc.fillRect(450, 320, 5, 50);
  90. gc.setFill(Color.PURPLE);
  91. gc.fillOval(450, 296, 6, 12);
  92. gc.fillOval(450, 313, 6, 12);
  93. gc.fillOval(436, 310, 12, 6);
  94. gc.fillOval(456, 310, 12, 6);
  95. gc.setFill(Color.YELLOW);
  96. gc.fillOval(447, 307, 10, 7);
  97.  
  98. gc.setFill(Color.LIMEGREEN);
  99. gc.fillRect(650, 310, 5, 50);
  100. gc.setFill(Color.PURPLE);
  101. gc.fillOval(650, 306, 6, 12);
  102. gc.fillOval(650, 323, 6, 12);
  103. gc.fillOval(636, 320, 12, 6);
  104. gc.fillOval(656, 320, 12, 6);
  105. gc.setFill(Color.YELLOW);
  106. gc.fillOval(647, 317, 10, 7);
  107.  
  108.  
  109. }
  110. };
  111.  
  112. timer.start();
  113.  
  114. }
  115.  
  116. public static void main(String[] args) {
  117. launch(args);
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement