forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteGFX142.java
More file actions
25 lines (22 loc) · 799 Bytes
/
WriteGFX142.java
File metadata and controls
25 lines (22 loc) · 799 Bytes
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
import java.io.PrintStream;
import java.awt.Toolkit;
import java.awt.Dimension;
import java.io.FileNotFoundException;
public class WriteGFX142{
public static void main(String[] args) throws FileNotFoundException{
// copied from chapter 5: set the width and height to be half the screen size
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int width = d.width / 2;
int height = d.height / 2;
PrintStream f = new PrintStream("sample3.gfx142");
f.println(width + " " + height);
for (int x = 0; x + 100 <= width; x = x + 100) {
if (x % 200 == 0) f.println("color 255 0 0");
else f.println("color 0 0 255");
for (int y = 0; y + 100 <= height; y = y + 100) {
f.println ("oval "+x+" "+y +" 100 100");
}
}
f.close();
}
}