Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add draw/fillTriangle.
[graphlib_java.git] / Exemple3.java
1 import java.util.*;
2
3 public class Exemple3 {
4
5     static final Random random = new Random();
6
7     public static void main(String[] args) {
8         // Création de la fenêtre
9         DrawingWindow w = new DrawingWindow("Exemple 3", 640, 480);
10
11         // Sans s'arrêter, affiche des lignes au hasard avec une
12         // couleur tirée aléatoirement
13         while (true) {
14             int x1 = random.nextInt(w.width);
15             int y1 = random.nextInt(w.height);
16             int x2 = random.nextInt(w.width);
17             int y2 = random.nextInt(w.height);
18             w.setColor(random.nextFloat(),
19                        random.nextFloat(),
20                        random.nextFloat());
21             w.drawLine(x1, y1, x2, y2);
22             w.sync();
23         }
24     }
25 }