Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. /*
  2. Mason Fisher
  3. 10/22/19
  4. Drawing a Town
  5. */
  6.  
  7. import javafx.application.Application;
  8. import javafx.stage.Stage;
  9. import javafx.scene.paint.*;
  10. import javafx.scene.canvas.*;
  11. import javafx.animation.AnimationTimer;
  12.  
  13.  
  14. public class Town0 extends Application {
  15. @Override
  16. public void start(Stage myStage) throws Exception {
  17. GraphicsContext gc = JIGraphicsUtility.setUpGraphics(myStage, "Town", 700, 700);
  18. AnimationTimer timer = new AnimationTimer() {
  19. double x = 0;
  20. @Override
  21. public void handle(long now) {
  22.  
  23. gc.setFill(Color.LIGHTSKYBLUE);
  24. gc.fillRect(0, 0, 700, 600);
  25.  
  26. gc.setFill(Color.SADDLEBROWN);
  27. gc.fillRect(0, 390, 700, 110);
  28.  
  29. gc.setFill(Color.CADETBLUE);
  30. gc.fillRect(45, 420, 60, 50);
  31. gc.fillRect(189, 420, 60, 50);
  32. gc.fillRect(359, 420, 60, 50);
  33. gc.fillRect(490, 420, 60, 50);
  34. gc.fillRect(630, 420, 60, 50);
  35.  
  36. gc.setFill(Color.GRAY);
  37. gc.fillRect(0, 475, 700, 300);
  38.  
  39. gc.setFill(Color.BLACK);
  40. gc.fillRect(150, 390, 10, 90);
  41. gc.fillRect(300, 390, 10, 90);
  42. gc.fillRect(450, 390, 10, 90);
  43. gc.fillRect(600, 390, 10, 90);
  44.  
  45. gc.setFill(Color.WHITE);
  46. gc.fillRect(30, 580, 40, 20);
  47. gc.fillRect(150, 580, 40, 20);
  48. gc.fillRect(270, 580, 40, 20);
  49. gc.fillRect(390, 580, 40, 20);
  50. gc.fillRect(510, 580, 40, 20);
  51. gc.fillRect(630, 580, 40, 20);
  52. gc.fillRect(750, 580, 40, 20);
  53.  
  54. //CLOUDS
  55. gc.setFill(Color.WHITESMOKE);
  56. gc.fillOval(230 + x, 100, 70, 50);
  57. gc.fillOval(240 + x, 110, 70, 50);
  58. gc.fillOval(220 + x, 110, 70, 50);
  59. gc.fillOval(530 + x, 100, 70, 50);
  60. gc.fillOval(540 + x, 110, 70, 50);
  61. gc.fillOval(520 + x, 110, 70, 50);
  62. gc.fillOval(030 + x, 100, 70, 50);
  63. gc.fillOval(040 + x, 110, 70, 50);
  64. gc.fillOval(020 + x, 110, 70, 50);
  65. gc.fillOval(270 + x, 150, 70, 50);
  66. gc.fillOval(280 + x, 160, 70, 50);
  67. gc.fillOval(280 + x, 160, 70, 50);
  68.  
  69. //SUN
  70. gc.setFill(Color.YELLOW);
  71. gc.fillOval(420, 10, 100, 100);
  72.  
  73. gc.strokeText("Walmart",50,415);
  74. gc.strokeText("711",180,415);
  75. gc.strokeText("Target",350,415);
  76. gc.strokeText("Taco Bell",500,415);
  77.  
  78. x ++;
  79. }
  80. };
  81. timer.start();
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement