Modify this program and draw something interesting. Maybe a car, a character, a tree, a happy face or anything else you like. Have at least 3 or 4 drawing commands in the program. Do some research on the Oracle web site to see what other JavaFX shapes you can include.Extra credit will be given if you include many different shapes and text. Include different fonts and different styles (Bold, Italic etc.) Be creative.
Please find the code below:
Smiley.java
package gui;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
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.Polygon;
import javafx.stage.Stage;
public class Smiley extends Application {
public void start(Stage primaryStage) {
// Create a stack pane
StackPane stackPane = new StackPane();
StackPane stackPane2 = new StackPane();
// Crate a pane
Pane pane = new Pane();
stackPane2.setPadding(new Insets(40, 40, 40, 40));
// Create a circle and place it in a stack pane
Circle circle = getCircle();
stackPane.getChildren().add(circle);
// Create a Polygon and place it in a stack pane
Polygon polygon = getPolygon(circle);
stackPane.getChildren().add(polygon);
// Create two ellipse
Ellipse ellipse1 = getEllipse(circle);
ellipse1.setCenterX(circle.getRadius() - circle.getRadius() / 2.5);
Ellipse ellipse2 = getEllipse(circle);
ellipse2.setCenterX(circle.getRadius() + circle.getRadius() / 2.5);
// Create two circles
Circle circle2 = getCircle(ellipse1);
circle2.setFill(Color.BLUE);
Circle circle3 = getCircle(ellipse2);
circle3.setFill(Color.BLUE);
// Create an Arc
Arc arc = getArc(circle);
// Place nodes in a pane
pane.getChildren().addAll(stackPane, ellipse1,
ellipse2, circle2, circle3, arc);
// Place pane in a stack pane
stackPane2.getChildren().add(pane);
// Create a scene and place it in the stage
Scene scene = new Scene(stackPane2);
primaryStage.setTitle("How to laugh"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}
/** Return a Arc of specified properties */
private Arc getArc(Circle c) {
Arc a = new Arc(c.getRadius(), c.getRadius() * 1.30,
c.getRadius() / 2, c.getRadius() / 4, 0, -180);
a.setType(ArcType.OPEN);
a.setFill(Color.ORANGE);
a.setStroke(Color.BLACK);
return a;
}
/** Return a circle of specified properties */
private Circle getCircle(Ellipse e) {
Circle c = new Circle(e.getCenterX(), e.getCenterY(),
e.getRadiusY() - (e.getRadiusX() - e.getRadiusY()));
return c;
}
/** Return an Ellipse of specified properties */
private Ellipse getEllipse(Circle c) {
Ellipse e = new Ellipse();
e.setCenterY(c.getRadius() - c.getRadius() / 3);
e.setRadiusX(c.getRadius() / 4);
e.setRadiusY(c.getRadius() / 3 - 20);
e.setStroke(Color.BLACK);
e.setFill(Color.WHITE);
return e;
}
/** Return a Polygon of specified properties */
private Polygon getPolygon(Circle c) {
double length = c.getRadius() / 4;
Polygon p = new Polygon(c.getCenterX(), c.getCenterY() - length,
c.getCenterX() - length, c.getCenterY() + length, c.getCenterX() + length,
c.getCenterY() + length);
p.setFill(Color.BROWN);
p.setStroke(Color.GREEN);
return p;
}
/** Returns a circle of specified properties */
private Circle getCircle() {
Circle c = new Circle();
c.setRadius(150);
c.setStroke(Color.BLACK);
c.setFill(Color.WHITE);
c.setFill(Color.LIGHTBLUE);
return c;
}
}
output:
Modify this program and draw something interesting. Maybe a car, a character, a tree, a happy...
Python Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following: How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. How to format each item of your inverted dictionary as a text string in the output file. Create an input file with your original...
Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...
Growing Plant program following guidelines Drawing Canvas Code: import java.awt.Canvas; import java.awt.*; import java.awt.geom.*; /** * */ /** */ public class DrawingCanvas extends Canvas { protected String drawString; protected double angleIncrement; DrawingCanvas() { this.setPreferredSize(new Dimension(400, 400)); } public void setDrawString(String s) { drawString = s; } public void setAngleIncrement(double d) { angleIncrement = Math.PI * d/ 180.0; } /** * Paint routine for our canvas. The upper Left hand corner * is 0, 0 and the lower right hand corner...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...