Advertisement
Omar_Natour

Natour, O. 4/4/16 Csc-112 Stan Marsh

Apr 4th, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.59 KB | None | 0 0
  1. /*
  2.  * Omar Natour
  3.  * 4/4/2016
  4.  * Csc-112 Java 2
  5.  * Hw#12
  6.  * Create Stan Marsh using Javafx
  7.  * Ojnatour0001@student.stcc.edu
  8.  */
  9.  
  10. import javafx.application.Application;
  11. import javafx.scene.Scene;
  12. import javafx.stage.Stage;
  13. import javafx.scene.layout.Pane;
  14. import javafx.scene.shape.*;
  15. import javafx.scene.paint.Color;
  16.  
  17. public class StanMarsh extends Application {
  18.     public static void main(String[] args) {
  19.         launch(args);
  20.     }
  21.  
  22.     @Override
  23.     public void start(Stage Primarystage) {
  24.         Pane pane = new Pane();
  25.        
  26.         pane.getChildren().add(Body());
  27.         pane.getChildren().add(Head());
  28.        
  29.         Scene sce = new Scene(pane,400, 460);
  30.  
  31.         Primarystage.setTitle("Stan Marsh");
  32.         Primarystage.setScene(sce);
  33.         Primarystage.show();
  34.         Primarystage.setResizable(false);
  35.     }
  36.  
  37.     public Pane Head() {
  38.         Pane head = new Pane();
  39.        
  40.         //Stan's Skin
  41.         Circle skin = new Circle();
  42.         skin.setCenterX(200);
  43.         skin.setCenterY(150);
  44.         skin.setRadius(110);
  45.         skin.setFill(Color.web("#FBD8B2"));
  46.        
  47.         //Blue part of hat
  48.         Arc hat = new Arc();
  49.         hat.setCenterX(200);
  50.         hat.setCenterY(120);
  51.         hat.setRadiusX(105);
  52.         hat.setRadiusY(83);
  53.         hat.setLength(180);
  54.         hat.setFill(Color.web("#4E60A0"));
  55.        
  56.         //Red part of hat
  57.         Arc brim1 = new Arc();
  58.         brim1.setCenterX(200);
  59.         brim1.setCenterY(140);
  60.         brim1.setRadiusX(130);
  61.         brim1.setRadiusY(28);
  62.         brim1.setFill(Color.TRANSPARENT);
  63.         brim1.setStrokeWidth(23);
  64.         brim1.setStroke(Color.web("#D31E3F"));
  65.         brim1.setLength(180);
  66.        
  67.         //used to block part of the above arc
  68.         Rectangle white = new Rectangle();
  69.         white.setX(312);
  70.         white.setY(100);
  71.         white.setHeight(70);
  72.         white.setWidth(30);
  73.         white.setFill(Color.WHITE);
  74.        
  75.         //used to block the other side of the above arc
  76.         Rectangle white2 = new Rectangle();
  77.         white2.setX(57.5);
  78.         white2.setY(100);
  79.         white2.setHeight(70);
  80.         white2.setWidth(30);
  81.         white2.setFill(Color.WHITE);
  82.        
  83.         //White part of left eye
  84.         Ellipse eyeL = new Ellipse();
  85.         eyeL.setCenterX(169);
  86.         eyeL.setCenterY(157);
  87.         eyeL.setRadiusX(33);
  88.         eyeL.setRadiusY(25);
  89.         eyeL.setFill(Color.web("#FDFDFD"));
  90.         eyeL.setRotate(122);
  91.        
  92.         //White part of right eye
  93.         Ellipse eyeR = new Ellipse();
  94.         eyeR.setCenterX(223);
  95.         eyeR.setCenterY(157);
  96.         eyeR.setRadiusX(33);
  97.         eyeR.setRadiusY(25);
  98.         eyeR.setFill(Color.web("#FDFDFD"));
  99.         eyeR.setRotate(58);
  100.        
  101.         //Black part of left eye
  102.         Circle eyeBallL = new Circle();
  103.         eyeBallL.setCenterX(179);
  104.         eyeBallL.setCenterY(160);
  105.         eyeBallL.setRadius(4);
  106.         eyeBallL.setFill(Color.BLACK);
  107.        
  108.         //Black part of right eye
  109.         Circle eyeBallR = new Circle();
  110.         eyeBallR.setCenterX(216);
  111.         eyeBallR.setCenterY(160);
  112.         eyeBallR.setRadius(4);
  113.         eyeBallR.setFill(Color.BLACK);
  114.        
  115.         //Black part of mouth
  116.         Arc mouth = new Arc();
  117.         mouth.setCenterX(200);
  118.         mouth.setCenterY(230);
  119.         mouth.setRadiusX(20);
  120.         mouth.setRadiusY(8);
  121.         mouth.setLength(180);
  122.         mouth.setFill(Color.rgb(0, 0, 0));
  123.         mouth.setStrokeWidth(3);
  124.         mouth.setRotate(10);
  125.        
  126.         // Skin colored arc to subtract what is unwanted in above arc
  127.         Arc mouth1 = new Arc();
  128.         mouth1.setCenterX(200);
  129.         mouth1.setCenterY(232);
  130.         mouth1.setRadiusX(21);
  131.         mouth1.setRadiusY(8);
  132.         mouth1.setLength(180);
  133.         mouth1.setFill(Color.web("#FBD8B2"));
  134.         mouth1.setRotate(7);
  135.        
  136.         //Black line between Stan's eyes
  137.         Arc nose = new Arc();
  138.         nose.setCenterX(196);
  139.         nose.setCenterY(150);
  140.         nose.setRadiusX(7);
  141.         nose.setRadiusY(.9);
  142.         nose.setLength(160);
  143.         nose.setFill(Color.TRANSPARENT);
  144.         nose.setStroke(Color.BLACK);
  145.         nose.setRotate(270);
  146.        
  147.         /////////////////////////////////////////////
  148.        
  149.         //adding everything in a semi-important order
  150.         head.getChildren().add(skin);
  151.         head.getChildren().add(hat);
  152.         head.getChildren().add(brim1);
  153.         head.getChildren().add(eyeL);
  154.         head.getChildren().add(eyeR);
  155.         head.getChildren().add(eyeBallL);
  156.         head.getChildren().add(eyeBallR);
  157.         head.getChildren().add(mouth);
  158.         head.getChildren().add(mouth1);
  159.         head.getChildren().add(nose);
  160.         head.getChildren().add(white);
  161.         head.getChildren().add(white2);
  162.  
  163.         // a loop for creating the poof thingy on top of Stan's head
  164.         for (int i = 0; i < 8; i++) {
  165.             Rectangle poof = new Rectangle();
  166.             poof.setX(175);
  167.             poof.setY(35);
  168.             poof.setHeight(4.5);
  169.             poof.setWidth(50);
  170.             poof.setArcWidth(5);
  171.             poof.setArcHeight(5);
  172.             poof.setFill(Color.web("#D31E3F"));
  173.             poof.setStroke(Color.BLACK);
  174.             poof.setStrokeWidth(.5);
  175.             poof.setRotate(337.5* i);
  176.             head.getChildren().add(poof);
  177.         }
  178.         return head;
  179.     }
  180.    
  181.     public Pane Body(){
  182.         Pane body = new Pane();
  183.    
  184.         //Center part of coat
  185.         Rectangle coat = new Rectangle();
  186.         coat.setX(125);
  187.         coat.setY(235);
  188.         coat.setWidth(150);
  189.         coat.setHeight(120);
  190.         coat.setFill(Color.web("#9C5C52"));
  191.        
  192.         //to fill in holes
  193.         Rectangle coat2 = new Rectangle();
  194.         coat2.setX(109);
  195.         coat2.setY(273);
  196.         coat2.setWidth(22);
  197.         coat2.setHeight(75);
  198.         coat2.setFill(Color.web("#9C5C52"));
  199.        
  200.         //to fill in holes
  201.         Rectangle coat3 = new Rectangle();
  202.         coat3.setX(100);
  203.         coat3.setY(273);
  204.         coat3.setWidth(20);
  205.         coat3.setHeight(50);
  206.         coat3.setFill(Color.web("#9C5C52"));
  207.        
  208.         //to fill in holes
  209.         Rectangle coat4 = new Rectangle();
  210.         coat4.setX(267);
  211.         coat4.setY(273);
  212.         coat4.setWidth(24);
  213.         coat4.setHeight(75);
  214.         coat4.setFill(Color.web("#9C5C52"));
  215.        
  216.         //to fill in holes
  217.         Rectangle coat5 = new Rectangle();
  218.         coat5.setX(267);
  219.         coat5.setY(273);
  220.         coat5.setWidth(28);
  221.         coat5.setHeight(60);
  222.         coat5.setFill(Color.web("#9C5C52"));
  223.  
  224.         //curve in bottom of the coat
  225.         Arc bottom = new Arc();
  226.         bottom.setCenterX(200);
  227.         bottom.setCenterY(360);
  228.         bottom.setRadiusX(90);
  229.         bottom.setRadiusY(12);
  230.         bottom.setFill(Color.web("#9C5C52"));
  231.         bottom.setRotate(180);
  232.         bottom.setLength(180);
  233.        
  234.         //curve that is the right shoulder on stan
  235.         Arc shoulderR = new Arc();
  236.         shoulderR.setCenterX(275);
  237.         shoulderR.setCenterY(273);
  238.         shoulderR.setRadiusX(90);
  239.         shoulderR.setRadiusY(35);
  240.         shoulderR.setLength(160);
  241.         shoulderR.setRotate(58);
  242.         shoulderR.setFill(Color.web("#9C5C52"));
  243.        
  244.         //curve that is the left shoulder on stan
  245.         Arc shoulderL = new Arc();
  246.         shoulderL.setCenterX(120);
  247.         shoulderL.setCenterY(273);
  248.         shoulderL.setRadiusX(90);
  249.         shoulderL.setRadiusY(35);
  250.         shoulderL.setLength(160);
  251.         shoulderL.setFill(Color.web("#9C5C52"));
  252.         shoulderL.setRotate(298);
  253.        
  254.         //right fist of stan
  255.         Circle handR = new Circle();
  256.         handR.setCenterX(303);
  257.         handR.setCenterY(325);
  258.         handR.setRadius(20);
  259.         handR.setFill(Color.web("#D31C3B"));
  260.        
  261.         //left fist of stan
  262.         Circle handL = new Circle();
  263.         handL.setCenterX(99);
  264.         handL.setCenterY(325);
  265.         handL.setRadius(20);
  266.         handL.setFill(Color.web("#D31C3B"));
  267.        
  268.         //left thumb
  269.         Circle thumbR = new Circle();
  270.         thumbR.setCenterX(286);
  271.         thumbR.setCenterY(320);
  272.         thumbR.setRadius(8);
  273.         thumbR.setFill(Color.web("#D31C3B"));
  274.         thumbR.setStrokeWidth(.5);
  275.         thumbR.setStroke(Color.BLACK);
  276.        
  277.         //left thumb
  278.         Circle thumbL = new Circle();
  279.         thumbL.setCenterX(115);
  280.         thumbL.setCenterY(320);
  281.         thumbL.setRadius(8);
  282.         thumbL.setFill(Color.web("#D31C3B"));
  283.         thumbL.setStrokeWidth(.5);
  284.         thumbL.setStroke(Color.BLACK);
  285.        
  286.         //Red collar on stans coat
  287.         Arc collar = new Arc();
  288.         collar.setCenterX(200);
  289.         collar.setCenterY(264);
  290.         collar.setRadiusX(89);
  291.         collar.setRadiusY(100);
  292.         collar.setLength(180);
  293.         collar.setFill(Color.TRANSPARENT);
  294.         collar.setRotate(180);
  295.         collar.setStroke(Color.web("#D31C3B"));
  296.         collar.setStrokeWidth(15);
  297.        
  298.         //top brown triangle on the collar of the coat
  299.         Polygon tri = new Polygon();
  300.         tri.getPoints().addAll(new Double[]{
  301.             197.0,260.0,
  302.             203.0,260.0,
  303.             200.0,267.0});
  304.         tri.setFill(Color.web("#9C5C52"));
  305.        
  306.         //upside down triangle on the collar of the coat
  307.         Polygon tri2 = new Polygon();
  308.         tri2.getPoints().addAll(new Double[]{
  309.             198.0,272.0,
  310.             202.0,272.0,
  311.             200.0,266.0});
  312.         tri2.setFill(Color.web("#9C5C52"));
  313.        
  314.         //vertical black line through the middle of the coat   
  315.         Rectangle zipper = new Rectangle();
  316.         zipper.setX(196);
  317.         zipper.setY(272);
  318.         zipper.setWidth(3);
  319.         zipper.setHeight(85);
  320.         zipper.setRotate(3);
  321.        
  322.         //top button
  323.         Circle but1 = new Circle();
  324.         but1.setCenterX(189.5);
  325.         but1.setCenterY(282);
  326.         but1.setRadius(3.5);
  327.        
  328.         //middle button
  329.         Circle but2 = new Circle();
  330.         but2.setCenterX(187);
  331.         but2.setCenterY(312);
  332.         but2.setRadius(3.5);
  333.        
  334.         //bottom button
  335.         Circle but3 = new Circle();
  336.         but3.setCenterX(186);
  337.         but3.setCenterY(342);
  338.         but3.setRadius(3.5);
  339.        
  340.         //line that divides torso from arm on left side
  341.         Arc pitL = new Arc();
  342.         pitL.setCenterX(115);
  343.         pitL.setCenterY(298);
  344.         pitL.setRadiusX(30);
  345.         pitL.setRadiusY(5);
  346.         pitL.setLength(-120);
  347.         pitL.setFill(Color.TRANSPARENT);
  348.         pitL.setStroke(Color.BLACK);
  349.         pitL.setStrokeWidth(1.5);
  350.         pitL.setRotate(105);
  351.        
  352.         //line that divides torso from arm on right side
  353.         Arc pitR = new Arc();
  354.         pitR.setCenterX(271.5);
  355.         pitR.setCenterY(302);
  356.         pitR.setRadiusX(30);
  357.         pitR.setRadiusY(5);
  358.         pitR.setLength(120);
  359.         pitR.setFill(Color.TRANSPARENT);
  360.         pitR.setStroke(Color.BLACK);
  361.         pitR.setStrokeWidth(1.5);
  362.         pitR.setRotate(69);
  363.        
  364.         //blue pants
  365.         Rectangle pants = new Rectangle();
  366.         pants.setX(118);
  367.         pants.setY(330);
  368.         pants.setWidth(164);
  369.         pants.setHeight(50);
  370.         pants.setFill(Color.web("#5867A8"));
  371.        
  372.         //Stan's left foot
  373.         Arc footL = new Arc();
  374.         footL.setCenterX(150);
  375.         footL.setCenterY(380);
  376.         footL.setRadiusX(55);
  377.         footL.setRadiusY(10);
  378.         footL.setFill(Color.web("#353336"));
  379.         footL.setLength(180);
  380.        
  381.         //Stan's right foot
  382.         Arc footR = new Arc();
  383.         footR.setCenterX(250);
  384.         footR.setCenterY(380);
  385.         footR.setRadiusX(55);
  386.         footR.setRadiusY(10);
  387.         footR.setFill(Color.web("#353336"));
  388.         footR.setLength(180);
  389.    
  390.         /////////////////////////////////////
  391.        
  392.         //Adding everything to the body pain in a semi-important order
  393.         body.getChildren().add(pants);
  394.         body.getChildren().add(footL);
  395.         body.getChildren().add(footR);
  396.         body.getChildren().add(coat);
  397.         body.getChildren().add(coat2);
  398.         body.getChildren().add(coat3);
  399.         body.getChildren().add(coat4);
  400.         body.getChildren().add(coat5);
  401.         body.getChildren().add(bottom);
  402.         body.getChildren().add(shoulderR);
  403.         body.getChildren().add(shoulderL);
  404.         body.getChildren().add(pitL);
  405.         body.getChildren().add(pitR);
  406.         body.getChildren().add(handR);
  407.         body.getChildren().add(handL);
  408.         body.getChildren().add(thumbR);
  409.         body.getChildren().add(thumbL);
  410.         body.getChildren().add(collar);
  411.         body.getChildren().add(tri);
  412.         body.getChildren().add(tri2);
  413.         body.getChildren().add(zipper);
  414.         body.getChildren().add(but1);
  415.         body.getChildren().add(but2);
  416.         body.getChildren().add(but3);
  417.        
  418.         return body;
  419.     }
  420. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement