2 public static void main(String[] args) {
3 DrawingWindow w1 = new DrawingWindow("Test!", 400, 300);
6 w1.setColor("lawngreen");
7 for (int i = 0; i < 12; i++) {
9 w1.drawLine(p, 0, p, w1.height - 1);
10 w1.drawLine(p + i, 0, p + i, w1.height - 1);
14 for (int i = 0; i < 12; i++) {
19 w1.drawText(150, y + 5, "circles");
20 w1.drawCircle(p, y, i);
22 w1.drawText(150, y + 5, "filled circles");
23 w1.fillCircle(p, y, i);
26 w1.drawText(150, y + 10, "rectangles with lines");
27 w1.drawLine(p, y, p, y + i);
28 w1.drawLine(p, y + i, p + i, y + i);
29 w1.drawLine(p + i, y + i, p + i, y);
30 w1.drawLine(p + i, y, p, y);
33 w1.drawText(150, y + 10, "rectangles");
34 w1.drawRect(p, y, p + i, y + i);
36 w1.drawText(150, y + 10, "filled rectangles");
37 w1.fillRect(p, y, p + i, y + i);
40 w1.drawText(150, y + 10, "triangles with lines");
41 w1.drawLine(p, y, p + i, y + i/2);
42 w1.drawLine(p + i, y + i/2, p, y + i);
43 w1.drawLine(p, y + i, p, y);
46 w1.drawText(150, y + 10, "triangles");
47 w1.drawTriangle(p, y, p + i, y + i/2, p, y + i);
49 w1.drawText(150, y + 10, "filled triangles");
50 w1.fillTriangle(p, y, p + i, y + i/2, p, y + i);
54 // Try out of bounds drawings
56 w1.drawLine(-10, w1.height - 10, w1.width + 10, w1.height - 10);
57 w1.drawLine(w1.width - 10, -10, w1.width - 10, w1.height + 10);
59 for (int x = -10; x <= w1.width + 10; x++) {
60 int y = w1.height - 20;
62 int c = w1.getPointColor(x, y);
63 if (c != (x < 0 || x >= w1.width ? 0 : 0x00ff0000))
64 throw new AssertionError("Error with getPointColor(): " +
65 "(" + x + ", " + y + "): " +
66 String.format("%#010x", c));
68 for (int y = -10; y <= w1.height + 10; y++) {
69 int x = w1.width - 20;
71 w1.getPointColor(x, y);
72 int c = w1.getPointColor(x, y);
73 if (c != (y < 0 || y >= w1.height ? 0 : 0x00ff0000))
74 throw new AssertionError("Error with getPointColor(): " +
75 "(" + x + ", " + y + "): " +
76 String.format("%#010x", c));
79 DrawingWindow w2 = new DrawingWindow("Test!", 800, 600);
82 for (int i = 0; i < 3; i++) {
84 for (int y = 0; y < w2.height; y++) {
85 for (int x = 0; x < w2.width; x++) {
91 for (int i = 0; i < 3; i++) {
93 for (int y = 0; y < w2.height; y++) {
94 for (int x = 0; x < w2.width; x++) {
102 System.out.println("Click anywhere on w1...");
104 w1.setColor("black");
105 while (w1.waitMousePress(5 * 1000)) {
106 int x = w1.getMouseX();
107 int y = w1.getMouseY();
108 System.out.println("[ " + x + " ; " + y + " ] - " +
109 w1.getMouseButton());
110 w1.drawLine(x - 5, y, x + 5, y);
111 w1.drawLine(x, y - 5, x, y + 5);
114 System.out.println("Done!");