2 public static void main(String[] args) {
3 DrawingWindow w1 = new DrawingWindow("Test!", 400, 300);
5 w1.setColor("lawngreen");
6 for (int i = 0; i < 12; i++) {
8 w1.drawLine(p, 0, p, 175);
9 w1.drawLine(p + i, 0, p + i, 175);
13 for (int i = 0; i < 12; i++) {
16 w1.drawCircle(p, 25, i);
17 w1.fillCircle(p, 50, i);
19 w1.drawRect(p, 75, p + i, 75 + i);
20 w1.fillRect(p, 100, p + i, 100 + i);
22 w1.drawTriangle(p, 125, p + i, 125 + i/2, p, 125 + i);
23 w1.fillTriangle(p, 150, p + i, 150 + i/2, p, 150 + i);
26 // Try out of bounds drawings
28 w1.drawLine(-10, w1.height - 10, w1.width + 10, w1.height - 10);
29 w1.drawLine(w1.width - 10, -10, w1.width - 10, w1.height + 10);
31 for (int x = -10; x <= w1.width + 10; x++) {
32 int y = w1.height - 20;
34 int c = w1.getPointColor(x, y);
35 if (c != (x < 0 || x >= w1.width ? 0 : 0x00ff0000))
36 throw new AssertionError("Error with getPointColor(): " +
37 "(" + x + ", " + y + "): " +
38 String.format("%#010x", c));
40 for (int y = -10; y <= w1.height + 10; y++) {
41 int x = w1.width - 20;
43 w1.getPointColor(x, y);
44 int c = w1.getPointColor(x, y);
45 if (c != (y < 0 || y >= w1.height ? 0 : 0x00ff0000))
46 throw new AssertionError("Error with getPointColor(): " +
47 "(" + x + ", " + y + "): " +
48 String.format("%#010x", c));
51 DrawingWindow w2 = new DrawingWindow("Test!", 800, 600);
54 for (int i = 0; i < 3; i++) {
56 for (int y = 0; y < w2.height; y++) {
57 for (int x = 0; x < w2.width; x++) {
63 for (int i = 0; i < 3; i++) {
65 for (int y = 0; y < w2.height; y++) {
66 for (int x = 0; x < w2.width; x++) {
74 System.out.println("Click anywhere on w1...");
77 while (w1.waitMousePress(5 * 1000)) {
78 int x = w1.getMouseX();
79 int y = w1.getMouseY();
80 System.out.println("[ " + x + " ; " + y + " ] - " +
82 w1.drawLine(x - 5, y, x + 5, y);
83 w1.drawLine(x, y - 5, x, y + 5);
86 System.out.println("Done!");