-
Notifications
You must be signed in to change notification settings - Fork 0
/
snowman.java
73 lines (59 loc) · 2.36 KB
/
snowman.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//************************************************************************
// Snowman.java Author: Lewis/Loftus
//
// Demonstrates the translation of a set of shapes.
//************************************************************************
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
public class snowman extends Application
{
//--------------------------------------------------------------------
// Presents a snowman scene.
//--------------------------------------------------------------------
public void start(Stage primaryStage)
{
Ellipse base = new Ellipse(80, 210, 80, 60);
base.setFill(Color.WHITE);
Ellipse middle = new Ellipse(80, 130, 50, 40);
middle.setFill(Color.WHITE);
Circle head = new Circle(80, 70, 30);
head.setFill(Color.WHITE);
Circle rightEye = new Circle(70, 60, 5);
Circle leftEye = new Circle(90, 60, 5);
Line mouth = new Line(70, 80, 90, 80);
Circle topButton = new Circle(80, 120, 6);
topButton.setFill(Color.RED);
Circle bottomButton = new Circle(80, 140, 6);
bottomButton.setFill(Color.RED);
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.setTranslateX(10);
hat.setRotate(15);
Group snowman = new Group(base, middle, head, leftEye, rightEye,
mouth, topButton, bottomButton, leftArm, rightArm, hat);
snowman.setTranslateX(170);
snowman.setTranslateY(50);
Circle sun = new Circle(50, 50, 30);
sun.setFill(Color.GOLD);
Rectangle ground = new Rectangle(0, 250, 500, 100);
ground.setFill(Color.STEELBLUE);
Group root = new Group(ground, sun, snowman);
Scene scene = new Scene(root, 500, 350, Color.LIGHTBLUE);
primaryStage.setTitle("Snowman");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args)
{
launch(args);
}
}