-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjacksonDrawing
More file actions
199 lines (184 loc) · 6.27 KB
/
jacksonDrawing
File metadata and controls
199 lines (184 loc) · 6.27 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import java.awt.*;
public class Doodle {
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(130,340);
Graphics g = panel.getGraphics();
Polygon hat = new Polygon();
Color brown = new Color(80,20,0);
panel.setBackground(Color.DARK_GRAY);
g.setColor(Color.WHITE);
g.fillOval(105,-20,50,50);
cloud(g,80,20,20);
cloud(g,80,40,20);
robe(g,20,160,80);
hand(g,72,235,25);
face(g,20,130,80);
hat(hat,g,10,10);
feet(g,25,306,30);
feet(g,65,306,30);
star(g,55,50);
star(g,67,65);
star(g,45,80);
star(g,77,90);
star(g,50,105);
star(g,85,120);
star(g,70,115);
star(g,32,130);
g.setColor(brown);
wideLine(g,80,250,100,180,10,brown,0);
magic(g,100,155,4);
magic(g,115,145,3);
magic(g,105,130,2);
magic(g,108,140,2);
magic(g,112,160,2);
magic(g,100,145,2);
}
//This makes the stars
public static void shape(Graphics g, int x, int y){
Polygon triangle1 = new Polygon();
Polygon triangle2 = new Polygon();
Polygon triangle3 = new Polygon();
triangle1.addPoint(x+4,y-2);
triangle1.addPoint(x+4,y+8);
triangle1.addPoint(x-8,y-2);
triangle2.addPoint(x+10,y-2);
triangle2.addPoint(x-4,y+8);
triangle2.addPoint(x-4,y-2);
triangle3.addPoint(x,y-8);
triangle3.addPoint(x-2,y-2);
triangle3.addPoint(x+2,y-2);
g.setColor(Color.YELLOW);
g.fillPolygon(triangle1);
g.fillPolygon(triangle2);
g.fillPolygon(triangle3);
}
public static void star(Graphics g,int x, int y) {
//This defines the stars' insides
shape(g, x, y);
//This prints the outline of the star
g.setColor(Color.BLACK);
g.drawLine(x,y-8,x+2,y-2);
g.drawLine(x+2,y-2,x+8,y-2);
g.drawLine(x+8,y-2,x+4,y+2);
g.drawLine(x+4,y+2,x+4,y+8);
g.drawLine(x+4,y+8,x,y+4);
g.drawLine(x,y+4,x-4,y+8);
g.drawLine(x-4,y+8,x-4,y+2);
g.drawLine(x-4,y+2,x-8,y-2);
g.drawLine(x-8,y-2,x-2,y-2);
g.drawLine(x-2,y-2,x,y-8);
}
//This makes the triangle for the hat and also the rectangle for the brim
public static void hat(Polygon hat,Graphics g,int x, int y) {
Color DarkBlue = new Color(0,0,150);
g.setColor(Color.BLUE);
hat.addPoint(x+50,y);
hat.addPoint(x,y+150);
hat.addPoint(x+100,y+150);
g.fillPolygon(hat);
g.setColor(Color.BLACK);
g.drawLine(x+50,y,x,y+150);
g.drawLine(x,y+150,x+100,y+150);
g.drawLine(x+100,y+150,x+50,y);
g.setColor(DarkBlue);
g.fillRect(x,y+130,100,20);
g.setColor(Color.BLACK);
g.drawRect(x,y+130,100,20);
g.drawLine(x,y+129,x+100,y+129);
}
//This makes a cloud
public static void cloud(Graphics g,int x, int y, int s){
g.setColor(Color.LIGHT_GRAY);
int x1 = (int)(Math.random()*x);
int y1 = (int)(Math.random()*y);
for(int i = 0; i < 4; i++){
g.fillOval(x1+s/2*i,y1+s/4*i,s,s);
g.fillOval(x1-s/2*i+s*4/2,y1+s/4*i,s,s);
g.fillOval(x1-s/2*i+s*4/2,y1-s/4*i,s,s);
g.fillOval(x1+s/2*i,y1-s/4*i,s,s);
}
}
//This prints a thinning line with a certain width
public static void wideLine(Graphics g, int x, int y, int x1, int x2, int s, Color DarkBrown, int section) {
for(int i = 0; i<s; i++) {
if(i>=0 & i<=(s-1))
g.setColor(DarkBrown);
if(i==s-1) {
g.setColor(Color.BLACK);
}
if(section==1)
g.setColor(Color.BLACK);
g.drawLine(x+i,y,x1+i/2,x2);
}
g.setColor(Color.BLACK);
g.drawLine(x,y,x1,x2);
g.drawLine(x1,x2,x1+s/2,x2);
g.drawLine(x,y,x+s,y);
}
public static void face(Graphics g, int x, int y, int s){
//25,135,55 This makes the base of the face
Polygon goatee = new Polygon();
Color skin = new Color(232,212,155);
g.setColor(skin);
g.fillOval(x,y,s,s);
//This makes the mouth and eyes
g.setColor(Color.BLACK);
g.drawOval(x,y,s,s);
g.fillOval(x+20,y+40,10,10);
g.fillOval(x+50,y+40,10,10);
g.drawLine(x+25,y+60,x+55,y+60);
//This makes the beard
g.setColor(Color.LIGHT_GRAY);
goatee.addPoint(x+30,y+70);
goatee.addPoint(x+50,y+70);
goatee.addPoint(x+40,y+90);
g.fillPolygon(goatee);
g.setColor(Color.BLACK);
g.drawPolygon(goatee);
}
//This prints the robe/cloak
public static void robe(Graphics g, int x, int y, int s){
Color DarkBlue = new Color(0,55,125);
g.setColor(DarkBlue);
g.fillOval(x,y,s,s);
g.setColor(Color.BLACK);
g.drawOval(x,y,s,s);
g.setColor(DarkBlue);
g.fillRect(x,y+s/2,s,s*3/2);
g.setColor(Color.BLACK);
g.drawRect(x,y+s/2,s,s*3/2);
g.setColor(DarkBlue);
g.drawLine(x+1,y+s/2,x-1+s,y+s/2);
g.setColor(Color.BLACK);
wideLine(g,x+s/2,y,x+s/2,y+s*2,2,DarkBlue,1);
}
//This prints the hands
public static void hand(Graphics g, int x, int y, int s){
Color skin = new Color(232,212,155);
g.setColor(skin);
g.fillOval(x,y,s,s);
g.setColor(Color.BLACK);
g.drawOval(x,y,s,s);
}
//This prints the feet
public static void feet(Graphics g, int x,int y,int s){
g.setColor(Color.BLACK);
g.fillOval(x,y,s,s);
g.setColor(Color.DARK_GRAY);
g.fillRect(x,y+s/2,s,s/2);
}
//This makes a lightning bolt!
public static void magic(Graphics g, int x, int y, int s){
Polygon lightning = new Polygon();
lightning.addPoint(x,y);
lightning.addPoint(x,y+2*s);
lightning.addPoint(x+2*s,y+3*s);
lightning.addPoint(x,y+6*s);
lightning.addPoint(x,y+4*s);
lightning.addPoint(x-2*s,y+3*s);
g.setColor(Color.YELLOW);
g.fillPolygon(lightning);
g.setColor(Color.BLACK);
g.drawPolygon(lightning);
}
}