Skip to content

Instantly share code, notes, and snippets.

@jananpatel2002
Created March 4, 2021 22:49
Show Gist options
  • Save jananpatel2002/a63b4143827f492c9a9ce02a2edd4b16 to your computer and use it in GitHub Desktop.
Save jananpatel2002/a63b4143827f492c9a9ce02a2edd4b16 to your computer and use it in GitHub Desktop.
/*
* Name: Janan Patel
* Date: 3/4/2021
* Course Number: CSC 112
* Course Name: Computer Science
* Problem Number: 6
* Email:jkpatel2001@student.stcc.edu
* Short Description of the Problem: Drawing Butters stotch from South Park.
*/
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
public class Butters extends Application {
private static final int APPWIDTH = 1280;
private static final int APPHEIGHT = 720;
private static final String TITLE = "Butters Picture";
private Pane buildGUI() {
Pane pane = new Pane();
Group group = new Group();
// The Face
var face = new Circle();
face.setRadius(100);
face.setFill(Color.rgb(255, 225, 196));
face.setCenterX(APPWIDTH / 2);
face.setCenterY(APPHEIGHT / 2 - 100);
// Hair
Polygon hair = new Polygon();
hair.getPoints().addAll(new Double[] { 640.0, 180.0, 580.0, 210.0, 600.0, 185.0, 550.0, 195.0, 605.0, 155.0,
590.0, 135.0, 630.0, 150.0, 670.0, 130.0, 665.0, 150.0, 720.0, 170.0, 700.0, 175.0, 715.0, 210.0 });
hair.setFill(Color.YELLOW);
// The Left Eye
Ellipse leftEye = new Ellipse();
leftEye.setRadiusX(20);
leftEye.setRadiusY(25);
leftEye.setFill(Color.WHITE);
leftEye.setCenterX(APPWIDTH / 2 - 21);
leftEye.setCenterY(APPHEIGHT / 2 - 100);
leftEye.setRotate(15);
leftEye.setStroke(Color.WHITE);
Circle littleCircleLeft = new Circle();
littleCircleLeft.setRadius(3.5);
littleCircleLeft.setFill(Color.BLACK);
littleCircleLeft.setCenterX(APPWIDTH / 2 - 15);
littleCircleLeft.setCenterY(APPHEIGHT / 2 - 100);
// The Right Eye
Ellipse rightEye = new Ellipse();
rightEye.setRadiusX(20);
rightEye.setRadiusY(25);
rightEye.setFill(Color.WHITE);
rightEye.setCenterX(APPWIDTH / 2 + 21);
rightEye.setCenterY(APPHEIGHT / 2 - 100);
rightEye.setRotate(-15);
rightEye.setStroke(Color.WHITE);
Circle littleCircleRight = new Circle();
littleCircleRight.setRadius(3.5);
littleCircleRight.setFill(Color.BLACK);
littleCircleRight.setCenterX(APPWIDTH / 2 + 15);
littleCircleRight.setCenterY(APPHEIGHT / 2 - 100);
// The Left Eye Brow
Line lEBrow = new Line();
lEBrow.setStartX(APPWIDTH / 2 - 50);
lEBrow.setStartY(APPHEIGHT / 2 - 115);
lEBrow.setEndX(APPWIDTH / 2 - 30);
lEBrow.setEndY(APPHEIGHT / 2 - 135);
lEBrow.setStrokeWidth(2.5);
// The Right Eye Brow
Line rEBrow = new Line();
rEBrow.setStartX(APPWIDTH / 2 + 50);
rEBrow.setStartY(APPHEIGHT / 2 - 115);
rEBrow.setEndX(APPWIDTH / 2 + 30);
rEBrow.setEndY(APPHEIGHT / 2 - 135);
rEBrow.setStrokeWidth(2.5);
// The Smile
Arc smile = new Arc();
smile.setCenterX(APPWIDTH / 2);
smile.setCenterY(APPHEIGHT / 2 - 50);
smile.setRadiusX(15);
smile.setRadiusY(7.5);
smile.setStartAngle(195);
smile.setLength(150);
smile.setType(ArcType.OPEN);
smile.setFill(Color.rgb(255, 225, 196));
smile.setStroke(Color.BLACK);
// The Shirt
Arc bottomArc = new Arc();
bottomArc.setCenterX(APPWIDTH / 2);
bottomArc.setCenterY(APPHEIGHT / 2 + 100);
bottomArc.setRadiusX(80);
bottomArc.setRadiusY(10);
bottomArc.setStartAngle(195);
bottomArc.setLength(150);
bottomArc.setType(ArcType.ROUND);
bottomArc.setFill(Color.rgb(91, 225, 198));
bottomArc.setStroke(Color.rgb(91, 225, 198));
Polygon shirtOutline = new Polygon();
shirtOutline.getPoints()
.addAll(new Double[] { 640.0, 360.0, 670.0, 340.0, 690.0, 340.0, 700.0, 350.0, 710.0, 370.0, 735.0,
450.0, 730.0, 460.0, 700.0, 485.0, 565.0, 462.0, 560.0, 450.0, 542.0, 440.0, 542.0, 420.0,
544.0, 410.0, 560.0, 360.0, 565.0, 350.0, 600.0, 310.0 });
shirtOutline.setFill(Color.rgb(91, 225, 198));
// Lines on his shirt
Line centerline = new Line();
centerline.setStartX(APPWIDTH / 2);
centerline.setStartY(APPHEIGHT / 2 + 1);
centerline.setEndX(APPWIDTH / 2);
centerline.setEndY(APPHEIGHT / 2 + 110);
centerline.setStrokeWidth(2.5);
Arc leftArmline = new Arc();
leftArmline.setCenterX(715);
leftArmline.setCenterY(420);
leftArmline.setRadiusX(16);
leftArmline.setRadiusY(2);
leftArmline.setStartAngle(190);
leftArmline.setLength(100);
leftArmline.setType(ArcType.OPEN);
leftArmline.setFill(Color.rgb(91, 225, 198));
leftArmline.setStroke(Color.BLACK);
leftArmline.setRotate(-115);
Arc rightArmline = new Arc();
rightArmline.setCenterX(575);
rightArmline.setCenterY(420);
rightArmline.setRadiusX(16);
rightArmline.setRadiusY(2);
rightArmline.setStartAngle(190);
rightArmline.setLength(100);
rightArmline.setType(ArcType.OPEN);
rightArmline.setFill(Color.rgb(91, 225, 198));
rightArmline.setStroke(Color.BLACK);
rightArmline.setRotate(110);
// Left Arm
Circle leftArm = new Circle();
leftArm.setFill(Color.rgb(232, 205, 178));
leftArm.setRadius(20);
leftArm.setCenterX(716);
leftArm.setCenterY(450);
Circle leftThumb = new Circle();
leftThumb.setFill(Color.rgb(232, 205, 178));
leftThumb.setRadius(10);
leftThumb.setStroke(Color.BLACK);
leftThumb.setCenterX(707);
leftThumb.setCenterY(440);
// Right Arm
Circle rightArm = new Circle();
rightArm.setFill(Color.rgb(232, 205, 178));
rightArm.setRadius(20);
rightArm.setCenterX(560);
rightArm.setCenterY(450);
Circle rightThumb = new Circle();
rightThumb.setFill(Color.rgb(232, 205, 178));
rightThumb.setRadius(10);
rightThumb.setStroke(Color.BLACK);
rightThumb.setCenterX(569);
rightThumb.setCenterY(440);
// Left Shoe
Arc leftShoe = new Arc();
leftShoe.setCenterX(590);
leftShoe.setCenterY(495);
leftShoe.setRadiusX(50);
leftShoe.setRadiusY(10);
leftShoe.setStartAngle(15);
leftShoe.setLength(150);
leftShoe.setType(ArcType.OPEN);
// Right Shoe
Arc rightShoe = new Arc();
rightShoe.setCenterX(685);
rightShoe.setCenterY(495);
rightShoe.setRadiusX(50);
rightShoe.setRadiusY(10);
rightShoe.setStartAngle(15);
rightShoe.setLength(150);
rightShoe.setType(ArcType.OPEN);
// Pants
Rectangle pants = new Rectangle(565, 462, 151, 30);
pants.setFill(Color.rgb(37, 105, 83));
pane.getChildren().addAll(shirtOutline, face, hair, lEBrow, rEBrow, leftEye, rightEye, littleCircleRight,
littleCircleLeft, smile, pants, leftShoe, rightShoe, bottomArc, rightArm, leftArm, leftThumb,
rightThumb, leftArmline, rightArmline, centerline);
return pane;
}
@Override
public void start(Stage primaryStage) throws Exception {
Scene scene = new Scene(buildGUI(), APPWIDTH, APPHEIGHT);
primaryStage.setTitle(TITLE);
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setResizable(false);
}
public static void main(String[] args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment