Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Omar Natour
- * 4/4/2016
- * Csc-112 Java 2
- * Hw#12
- * Create Stan Marsh using Javafx
- * Ojnatour0001@student.stcc.edu
- */
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.stage.Stage;
- import javafx.scene.layout.Pane;
- import javafx.scene.shape.*;
- import javafx.scene.paint.Color;
- public class StanMarsh extends Application {
- public static void main(String[] args) {
- launch(args);
- }
- @Override
- public void start(Stage Primarystage) {
- Pane pane = new Pane();
- pane.getChildren().add(Body());
- pane.getChildren().add(Head());
- Scene sce = new Scene(pane,400, 460);
- Primarystage.setTitle("Stan Marsh");
- Primarystage.setScene(sce);
- Primarystage.show();
- Primarystage.setResizable(false);
- }
- public Pane Head() {
- Pane head = new Pane();
- //Stan's Skin
- Circle skin = new Circle();
- skin.setCenterX(200);
- skin.setCenterY(150);
- skin.setRadius(110);
- skin.setFill(Color.web("#FBD8B2"));
- //Blue part of hat
- Arc hat = new Arc();
- hat.setCenterX(200);
- hat.setCenterY(120);
- hat.setRadiusX(105);
- hat.setRadiusY(83);
- hat.setLength(180);
- hat.setFill(Color.web("#4E60A0"));
- //Red part of hat
- Arc brim1 = new Arc();
- brim1.setCenterX(200);
- brim1.setCenterY(140);
- brim1.setRadiusX(130);
- brim1.setRadiusY(28);
- brim1.setFill(Color.TRANSPARENT);
- brim1.setStrokeWidth(23);
- brim1.setStroke(Color.web("#D31E3F"));
- brim1.setLength(180);
- //used to block part of the above arc
- Rectangle white = new Rectangle();
- white.setX(312);
- white.setY(100);
- white.setHeight(70);
- white.setWidth(30);
- white.setFill(Color.WHITE);
- //used to block the other side of the above arc
- Rectangle white2 = new Rectangle();
- white2.setX(57.5);
- white2.setY(100);
- white2.setHeight(70);
- white2.setWidth(30);
- white2.setFill(Color.WHITE);
- //White part of left eye
- Ellipse eyeL = new Ellipse();
- eyeL.setCenterX(169);
- eyeL.setCenterY(157);
- eyeL.setRadiusX(33);
- eyeL.setRadiusY(25);
- eyeL.setFill(Color.web("#FDFDFD"));
- eyeL.setRotate(122);
- //White part of right eye
- Ellipse eyeR = new Ellipse();
- eyeR.setCenterX(223);
- eyeR.setCenterY(157);
- eyeR.setRadiusX(33);
- eyeR.setRadiusY(25);
- eyeR.setFill(Color.web("#FDFDFD"));
- eyeR.setRotate(58);
- //Black part of left eye
- Circle eyeBallL = new Circle();
- eyeBallL.setCenterX(179);
- eyeBallL.setCenterY(160);
- eyeBallL.setRadius(4);
- eyeBallL.setFill(Color.BLACK);
- //Black part of right eye
- Circle eyeBallR = new Circle();
- eyeBallR.setCenterX(216);
- eyeBallR.setCenterY(160);
- eyeBallR.setRadius(4);
- eyeBallR.setFill(Color.BLACK);
- //Black part of mouth
- Arc mouth = new Arc();
- mouth.setCenterX(200);
- mouth.setCenterY(230);
- mouth.setRadiusX(20);
- mouth.setRadiusY(8);
- mouth.setLength(180);
- mouth.setFill(Color.rgb(0, 0, 0));
- mouth.setStrokeWidth(3);
- mouth.setRotate(10);
- // Skin colored arc to subtract what is unwanted in above arc
- Arc mouth1 = new Arc();
- mouth1.setCenterX(200);
- mouth1.setCenterY(232);
- mouth1.setRadiusX(21);
- mouth1.setRadiusY(8);
- mouth1.setLength(180);
- mouth1.setFill(Color.web("#FBD8B2"));
- mouth1.setRotate(7);
- //Black line between Stan's eyes
- Arc nose = new Arc();
- nose.setCenterX(196);
- nose.setCenterY(150);
- nose.setRadiusX(7);
- nose.setRadiusY(.9);
- nose.setLength(160);
- nose.setFill(Color.TRANSPARENT);
- nose.setStroke(Color.BLACK);
- nose.setRotate(270);
- /////////////////////////////////////////////
- //adding everything in a semi-important order
- head.getChildren().add(skin);
- head.getChildren().add(hat);
- head.getChildren().add(brim1);
- head.getChildren().add(eyeL);
- head.getChildren().add(eyeR);
- head.getChildren().add(eyeBallL);
- head.getChildren().add(eyeBallR);
- head.getChildren().add(mouth);
- head.getChildren().add(mouth1);
- head.getChildren().add(nose);
- head.getChildren().add(white);
- head.getChildren().add(white2);
- // a loop for creating the poof thingy on top of Stan's head
- for (int i = 0; i < 8; i++) {
- Rectangle poof = new Rectangle();
- poof.setX(175);
- poof.setY(35);
- poof.setHeight(4.5);
- poof.setWidth(50);
- poof.setArcWidth(5);
- poof.setArcHeight(5);
- poof.setFill(Color.web("#D31E3F"));
- poof.setStroke(Color.BLACK);
- poof.setStrokeWidth(.5);
- poof.setRotate(337.5* i);
- head.getChildren().add(poof);
- }
- return head;
- }
- public Pane Body(){
- Pane body = new Pane();
- //Center part of coat
- Rectangle coat = new Rectangle();
- coat.setX(125);
- coat.setY(235);
- coat.setWidth(150);
- coat.setHeight(120);
- coat.setFill(Color.web("#9C5C52"));
- //to fill in holes
- Rectangle coat2 = new Rectangle();
- coat2.setX(109);
- coat2.setY(273);
- coat2.setWidth(22);
- coat2.setHeight(75);
- coat2.setFill(Color.web("#9C5C52"));
- //to fill in holes
- Rectangle coat3 = new Rectangle();
- coat3.setX(100);
- coat3.setY(273);
- coat3.setWidth(20);
- coat3.setHeight(50);
- coat3.setFill(Color.web("#9C5C52"));
- //to fill in holes
- Rectangle coat4 = new Rectangle();
- coat4.setX(267);
- coat4.setY(273);
- coat4.setWidth(24);
- coat4.setHeight(75);
- coat4.setFill(Color.web("#9C5C52"));
- //to fill in holes
- Rectangle coat5 = new Rectangle();
- coat5.setX(267);
- coat5.setY(273);
- coat5.setWidth(28);
- coat5.setHeight(60);
- coat5.setFill(Color.web("#9C5C52"));
- //curve in bottom of the coat
- Arc bottom = new Arc();
- bottom.setCenterX(200);
- bottom.setCenterY(360);
- bottom.setRadiusX(90);
- bottom.setRadiusY(12);
- bottom.setFill(Color.web("#9C5C52"));
- bottom.setRotate(180);
- bottom.setLength(180);
- //curve that is the right shoulder on stan
- Arc shoulderR = new Arc();
- shoulderR.setCenterX(275);
- shoulderR.setCenterY(273);
- shoulderR.setRadiusX(90);
- shoulderR.setRadiusY(35);
- shoulderR.setLength(160);
- shoulderR.setRotate(58);
- shoulderR.setFill(Color.web("#9C5C52"));
- //curve that is the left shoulder on stan
- Arc shoulderL = new Arc();
- shoulderL.setCenterX(120);
- shoulderL.setCenterY(273);
- shoulderL.setRadiusX(90);
- shoulderL.setRadiusY(35);
- shoulderL.setLength(160);
- shoulderL.setFill(Color.web("#9C5C52"));
- shoulderL.setRotate(298);
- //right fist of stan
- Circle handR = new Circle();
- handR.setCenterX(303);
- handR.setCenterY(325);
- handR.setRadius(20);
- handR.setFill(Color.web("#D31C3B"));
- //left fist of stan
- Circle handL = new Circle();
- handL.setCenterX(99);
- handL.setCenterY(325);
- handL.setRadius(20);
- handL.setFill(Color.web("#D31C3B"));
- //left thumb
- Circle thumbR = new Circle();
- thumbR.setCenterX(286);
- thumbR.setCenterY(320);
- thumbR.setRadius(8);
- thumbR.setFill(Color.web("#D31C3B"));
- thumbR.setStrokeWidth(.5);
- thumbR.setStroke(Color.BLACK);
- //left thumb
- Circle thumbL = new Circle();
- thumbL.setCenterX(115);
- thumbL.setCenterY(320);
- thumbL.setRadius(8);
- thumbL.setFill(Color.web("#D31C3B"));
- thumbL.setStrokeWidth(.5);
- thumbL.setStroke(Color.BLACK);
- //Red collar on stans coat
- Arc collar = new Arc();
- collar.setCenterX(200);
- collar.setCenterY(264);
- collar.setRadiusX(89);
- collar.setRadiusY(100);
- collar.setLength(180);
- collar.setFill(Color.TRANSPARENT);
- collar.setRotate(180);
- collar.setStroke(Color.web("#D31C3B"));
- collar.setStrokeWidth(15);
- //top brown triangle on the collar of the coat
- Polygon tri = new Polygon();
- tri.getPoints().addAll(new Double[]{
- 197.0,260.0,
- 203.0,260.0,
- 200.0,267.0});
- tri.setFill(Color.web("#9C5C52"));
- //upside down triangle on the collar of the coat
- Polygon tri2 = new Polygon();
- tri2.getPoints().addAll(new Double[]{
- 198.0,272.0,
- 202.0,272.0,
- 200.0,266.0});
- tri2.setFill(Color.web("#9C5C52"));
- //vertical black line through the middle of the coat
- Rectangle zipper = new Rectangle();
- zipper.setX(196);
- zipper.setY(272);
- zipper.setWidth(3);
- zipper.setHeight(85);
- zipper.setRotate(3);
- //top button
- Circle but1 = new Circle();
- but1.setCenterX(189.5);
- but1.setCenterY(282);
- but1.setRadius(3.5);
- //middle button
- Circle but2 = new Circle();
- but2.setCenterX(187);
- but2.setCenterY(312);
- but2.setRadius(3.5);
- //bottom button
- Circle but3 = new Circle();
- but3.setCenterX(186);
- but3.setCenterY(342);
- but3.setRadius(3.5);
- //line that divides torso from arm on left side
- Arc pitL = new Arc();
- pitL.setCenterX(115);
- pitL.setCenterY(298);
- pitL.setRadiusX(30);
- pitL.setRadiusY(5);
- pitL.setLength(-120);
- pitL.setFill(Color.TRANSPARENT);
- pitL.setStroke(Color.BLACK);
- pitL.setStrokeWidth(1.5);
- pitL.setRotate(105);
- //line that divides torso from arm on right side
- Arc pitR = new Arc();
- pitR.setCenterX(271.5);
- pitR.setCenterY(302);
- pitR.setRadiusX(30);
- pitR.setRadiusY(5);
- pitR.setLength(120);
- pitR.setFill(Color.TRANSPARENT);
- pitR.setStroke(Color.BLACK);
- pitR.setStrokeWidth(1.5);
- pitR.setRotate(69);
- //blue pants
- Rectangle pants = new Rectangle();
- pants.setX(118);
- pants.setY(330);
- pants.setWidth(164);
- pants.setHeight(50);
- pants.setFill(Color.web("#5867A8"));
- //Stan's left foot
- Arc footL = new Arc();
- footL.setCenterX(150);
- footL.setCenterY(380);
- footL.setRadiusX(55);
- footL.setRadiusY(10);
- footL.setFill(Color.web("#353336"));
- footL.setLength(180);
- //Stan's right foot
- Arc footR = new Arc();
- footR.setCenterX(250);
- footR.setCenterY(380);
- footR.setRadiusX(55);
- footR.setRadiusY(10);
- footR.setFill(Color.web("#353336"));
- footR.setLength(180);
- /////////////////////////////////////
- //Adding everything to the body pain in a semi-important order
- body.getChildren().add(pants);
- body.getChildren().add(footL);
- body.getChildren().add(footR);
- body.getChildren().add(coat);
- body.getChildren().add(coat2);
- body.getChildren().add(coat3);
- body.getChildren().add(coat4);
- body.getChildren().add(coat5);
- body.getChildren().add(bottom);
- body.getChildren().add(shoulderR);
- body.getChildren().add(shoulderL);
- body.getChildren().add(pitL);
- body.getChildren().add(pitR);
- body.getChildren().add(handR);
- body.getChildren().add(handL);
- body.getChildren().add(thumbR);
- body.getChildren().add(thumbL);
- body.getChildren().add(collar);
- body.getChildren().add(tri);
- body.getChildren().add(tri2);
- body.getChildren().add(zipper);
- body.getChildren().add(but1);
- body.getChildren().add(but2);
- body.getChildren().add(but3);
- return body;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement