luliu

Stan Marsh Pane Class

Apr 1st, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.44 KB | None | 0 0
  1. *
  2.  * Name: Lu Liu
  3.  * Date: 4/1/2016
  4.  * Course Number: CSC-112
  5.  * Course Name: Intermediate Topics in Java Programming
  6.  * Email: lliu0001@student.stcc.edu
  7.  *
  8.  * Assignment: HW # 12
  9.  * Programe Description:
  10. * Stan Marsh Pane Class
  11.  * South Park's Stan Marsh Rendering Graphics Assignment
  12. *
  13. */
  14.  
  15. import javafx.application.Application;
  16. import javafx.scene.Group;
  17. import javafx.scene.Scene;
  18. import javafx.scene.image.Image;
  19. import javafx.scene.image.ImageView;
  20. import javafx.scene.layout.BorderPane;
  21. import javafx.scene.layout.HBox;
  22. import javafx.scene.layout.Pane;
  23. import javafx.scene.layout.StackPane;
  24. import javafx.scene.paint.Color;
  25. import javafx.stage.Stage;
  26. import javafx.scene.shape.Arc;
  27. import javafx.scene.shape.ArcType;
  28. import javafx.scene.shape.Circle;
  29. import javafx.scene.shape.Ellipse;
  30. import javafx.scene.shape.Line;
  31. import javafx.scene.shape.Rectangle;
  32.  
  33. public class StanMarchPane extends Pane {
  34.  
  35.     public StanMarchPane() {
  36.         draw();
  37.     }
  38.  
  39.     public void draw() {
  40.         Pane pane = new Pane();
  41.         // boby
  42.         Rectangle r1 = new Rectangle(100, 260, 160, 130);
  43.         r1.setFill(Color.rgb(159, 91, 84));
  44.  
  45.         // arms
  46.         Arc arc1 = new Arc(180, 340, 120, 120, 0 + 15, 150);
  47.         arc1.setType(ArcType.CHORD);
  48.         arc1.setFill(Color.rgb(159, 91, 84));
  49.  
  50.         // clothes line
  51.         Line line = new Line(180, 305, 180, 380);
  52.         line.setStroke(Color.BLACK);
  53.         line.setStrokeWidth(3);
  54.         line.setRotate(5);
  55.  
  56.         // buttons and hands
  57.         Circle c1 = new Circle(170, 320, 3, Color.BLACK);
  58.         Circle c2 = new Circle(169, 338, 3, Color.BLACK);
  59.         Circle c3 = new Circle(168, 355, 3, Color.BLACK);
  60.         Circle c4 = new Circle(80, 325, 25, Color.RED);
  61.         Circle c5 = new Circle(100, 315, 10, Color.RED);
  62.         c5.setStroke(Color.BLACK);
  63.         Circle c6 = new Circle(280, 325, 25, Color.RED);
  64.         Circle c7 = new Circle(260, 315, 10, Color.RED);
  65.         c7.setStroke(Color.BLACK);
  66.  
  67.         // legs
  68.         Rectangle r2 = new Rectangle(110, 390, 140, 20);
  69.         r2.setFill(Color.rgb(78, 99, 157));
  70.  
  71.         // foot 1
  72.         Arc arc2 = new Arc(145, 480, 80, 80, 0 + 57, 65);
  73.         arc2.setFill(Color.BLACK);
  74.         arc2.setType(ArcType.CHORD);
  75.         arc2.setStroke(Color.BLACK);
  76.         // foot 2
  77.         Arc arc3 = new Arc(215, 480, 80, 80, 0 + 57, 65);
  78.         arc3.setFill(Color.BLACK);
  79.         arc3.setType(ArcType.CHORD);
  80.         arc3.setStroke(Color.BLACK);
  81.  
  82.         // face
  83.         Circle face = new Circle(180, 180, 120);
  84.         face.setFill(Color.rgb(252, 216, 182));
  85.         face.setStrokeWidth(1);
  86.  
  87.         // eye
  88.         Ellipse e1 = new Ellipse(220, 190, 40, 30);
  89.         Ellipse e2 = new Ellipse(150, 190, 40, 30);
  90.         Circle e3 = new Circle(160, 190, 5);
  91.         Circle e4 = new Circle(210, 190, 5);
  92.         e1.setFill(Color.WHITE);
  93.         e2.setFill(Color.WHITE);
  94.         e3.setFill(Color.BLACK);
  95.         e4.setFill(Color.BLACK);
  96.         e2.setRotate(135);
  97.         e1.setRotate(45);
  98.  
  99.         // mouth
  100.         Arc arc4 = new Arc(188, 330, 80, 80, 75, 35);
  101.         arc4.setFill(Color.BLACK);
  102.         arc4.setType(ArcType.OPEN);
  103.        
  104.         //hat
  105.         Arc arc5 = new Arc(180, 180, 120, 120, 0 + 15, 150);
  106.         arc5.setType(ArcType.CHORD);
  107.         arc5.setFill(Color.rgb(76, 97, 155));
  108.  
  109.         //hatband
  110.         Rectangle r3 = new Rectangle(60, 120, 240, 30);
  111.         r3.setFill(Color.RED);
  112.  
  113.         getChildren().clear();
  114.         getChildren().addAll(r1, arc1, line, c1, c2, c3, c4, c5, c6, c7, r2, arc2, arc3, face, e1, e2, e3, e4, arc4,
  115.                 arc5, r3);
  116.  
  117.         // hat top
  118.         for (int i = 0; i < 10; i++) {
  119.             Rectangle r4 = new Rectangle(150, 60, 60, 3);
  120.             r4.setRotate(i * 360 / 14);
  121.             r4.setFill(Color.RED);
  122.             r4.setStroke(Color.BLACK);
  123.             getChildren().add(r4);
  124.         }
  125.     }
  126. }
Add Comment
Please, Sign In to add comment