E569 andersonda/ThinkJavaCode2@ff296f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff296f8

Browse files
committed
added oval examples to ResizeDrawing
1 parent 454a20e commit ff296f8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ch05/ResizeDrawing.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33

44
public class ResizeDrawing {
55
public static void draw(Graphics g, int width, int height) {
6-
g.drawOval(x, 0, 100, 100);
6+
// g.drawOval(0, 0, 100, 100); // circle in upper left corner of window
7+
// g.drawOval(width / 2, height / 2, 100, 100); // circle with upper left "corner" in center of window
8+
// g.drawOval(width / 2 - 50, height / 2 - 50, 100, 100); // circle with center in center of window
9+
10+
// draw a line of circles (using while loop)
11+
// int x = 0;
12+
// while (x + 100 <= width) {
13+
// g.drawOval(x, 0, 100, 100);
14+
// x += 10;
15+
// }
16+
17+
// draw a line of circles (using for loop)
18+
for(int i = 0; i + 100 <= width; i++){
19+
g.drawOval(x, 0, 100, 100);
20+
}
721
}
822

923
// Leave the main method alone! It just sets up the drawing window for you.

0 commit comments

Comments
 (0)
0