Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d3e4e6268ef64f2f33f9571f05263968934661e4
[graphlib_java.git] / Test.java
1 class Test{
2     public static void main(String[] args) {
3         DrawingWindow w1 = new DrawingWindow("Test!", 400, 400);
4         w1.setColor("lawngreen");
5         for (int i = 0; i < 12; i++) {
6             int p = 10 * i + 10;
7             w1.drawLine(p, 0, p, 175);
8             w1.drawLine(p + i, 0, p + i, 175);
9         }
10
11         w1.setColor("black");
12         for (int i = 0; i < 12; i++) {
13             int p = 10 * i + 10;
14
15             w1.drawCircle(p, 25, i);
16             w1.fillCircle(p, 50, i);
17
18             w1.drawRect(p, 75, p + i, 75 + i);
19             w1.fillRect(p, 100, p + i, 100 + i);
20
21             w1.drawTriangle(p, 125, p + i, 125 + i/2, p, 125 + i);
22             w1.fillTriangle(p, 150, p + i, 150 + i/2, p, 150 + i);
23         }
24
25         DrawingWindow w2 = new DrawingWindow("Test!", 800, 600);
26         w2.setBgColor("red");
27         w2.setColor("blue");
28         for (int i = 0; i < 3; i++) {
29             w2.clearGraph();
30             for (int y = 0; y < w2.height; y++) {
31                 for (int x = 0; x < w2.width; x++) {
32                     w2.drawPoint(x, y);
33                 }
34             }
35         }
36         w2.setColor("white");
37         for (int i = 0; i < 3; i++) {
38             w2.clearGraph();
39             for (int y = 0; y < w2.height; y++) {
40                 for (int x = 0; x < w2.width; x++) {
41                     w2.drawPoint(x, y);
42                 }
43                 w2.sync();
44             }
45         }
46         w2.closeGraph();
47
48         System.out.println("Click anywhere on w1...");
49
50         while (w1.waitMousePress(5 * 1000)) {
51             int x = w1.getMouseX();
52             int y = w1.getMouseY();
53             System.out.println("[ " + x + " ; " + y + " ] - " +
54                                w1.getMouseButton());
55             w1.drawLine(x - 5, y, x + 5, y);
56             w1.drawLine(x, y - 5, x, y + 5);
57         }
58
59         System.out.println("Done!");
60     }
61 }