Question
Write a JavaFX Application that draws a picture of a flower in spring. You can make it fairly crude. The Snowman Application in chapter 3
Write a JavaFX Application that draws a picture of a flower in spring. You can make it fairly crude. The Snowman Application in chapter 3 should have everything you need. Look at Chortle chapters 120 and 121 for additional examples. How to Do It: Play with the snowman Application to get an idea of what can be done. Fuss with rotation and translation. Change some colors. Extend the Java class Application, as done with the snowman. Use thick lines for stalks and rotated ellipses for petals. Put the sky and the ground as background. Dont worry terribly about artistic quality. This can look like a child's drawing. It should take about 45 to 75 statements, not counting documentation and blank lines. You can do this as a BlueJ project or as a source filed edited with Notepad++. This is the Snowman application: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.shape.*; import javafx.scene.paint.Color; import javafx.scene.text.Text; import javafx.stage.Stage; public class Snowman extends Application { public void start( Stage primaryStage ) { Ellipse base = new Ellipse( 80, 210, 80, 60 ); base.setFill( Color.WHITE ); Ellipse middle = new Ellipse( 80, 130, 60, 40 ); middle.setFill( Color.WHITE ); Circle head = new Circle( 80, 70, 30 ); head.setFill( Color.WHITE ); Circle rightEye = new Circle( 70, 60, 5 ); rightEye.setFill( Color.BLACK ); Circle leftEye = new Circle( 90, 60, 5 ); leftEye.setFill( Color.BLACK ); Line mouth = new Line( 70, 80, 90, 80 ); Circle topButton = new Circle( 80, 120, 6 ) ; topButton.setFill( Color.BLACK ); Circle botButton = new Circle( 80, 140, 6 ) ; botButton.setFill( Color.BLACK ); Circle botBButton = new Circle( 80, 160, 6 ) ; botBButton.setFill( Color.BLACK ); Line leftArm = new Line( 110, 130, 160, 130 ); leftArm.setStrokeWidth( 3 ); Line rightArm = new Line( 50, 130, 0, 100 ); rightArm.setStrokeWidth( 3 ); Rectangle stovepipe = new Rectangle( 60, 0, 40, 50 ); Rectangle brim = new Rectangle( 50, 45, 60, 5 ); Group hat = new Group( stovepipe, brim ); hat.setRotate( 15 ); hat.setTranslateX( 10 ); Group body = new Group( base, middle, head ); Group face = new Group( leftEye, rightEye, mouth ); Group buttons = new Group( topButton, botButton, botBButton ); Group arms = new Group( leftArm, rightArm ); Group snowman = new Group( body, face, buttons, arms, hat ); snowman.setTranslateX( 200 ); snowman.setTranslateY( 50 ); snowman.setRotate(15.0); Circle sun = new Circle( 0, 0, 30 ); sun.setFill( Color.GOLD ); sun.setTranslateX( 60 ); sun.setTranslateY( 60 ); Rectangle ground = new Rectangle( 0, 250, 500, 100 ); ground.setFill( Color.GREEN ); Group root = new Group( ground, sun, snowman ); Scene scene = new Scene( root, 500, 350, Color.RED ); primaryStage.setTitle( "Snowman" ); primaryStage.setScene( scene ); primaryStage.show(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started