Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add comments to examples.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 9 Oct 2014 12:29:33 +0000 (14:29 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 9 Oct 2014 12:29:33 +0000 (14:29 +0200)
Exemple1.java
Exemple2.java
Exemple3.java
Hello.java
TODO

index 9a26184..5530ffd 100644 (file)
@@ -1,8 +1,11 @@
 public class Exemple1 {
 
     public static void main(String[] args) {
+        // Création de la fenêtre
         DrawingWindow w = new DrawingWindow("Exemple 1", 640, 480);
 
+        // Affichage d'un ensemble de lignes, du centre de la fenêtre
+        // vers les bords
         final int cx = w.width / 2;
         final int cy = w.height / 2;
         final int delta = 5;
index 1cff9d9..0043e5b 100644 (file)
@@ -3,10 +3,13 @@ import java.util.*;
 public class Exemple2 {
 
     public static void main(String[] args) {
+        // Création de la fenêtre
         DrawingWindow w = new DrawingWindow("Exemple 3", 640, 480);
 
         int width = Math.min(w.width - 1, w.height - 1) / 2;
 
+        // Affichage de rectangles concentriques, avec un dégradé de
+        // couleurs
         for (int z = 0; z <= width; z++) {
             float r, g, b;
             float s = 3.0f * z / width;
@@ -25,7 +28,9 @@ public class Exemple2 {
                 g = 0.0f;
                 b = 1.0f - s;
             }
+            // On change la couleur de dessin...
             w.setColor(r, g, b);
+            // ... et on affiche un rectangle
             w.drawRect(z, z, w.width - 1 - z, w.height - 1 - z);
         }
     }
index 2b488d1..4a6aff8 100644 (file)
@@ -5,10 +5,12 @@ public class Exemple3 {
     static final Random random = new Random();
 
     public static void main(String[] args) {
+        // Création de la fenêtre
         DrawingWindow w = new DrawingWindow("Exemple 3", 640, 480);
 
-        for (int i = 0; ; i++) {
-
+        // Sans s'arrêter, affiche des lignes au hasard avec une
+        // couleur tirée aléatoirement
+        while (true) {
             int x1 = random.nextInt(w.width);
             int y1 = random.nextInt(w.height);
             int x2 = random.nextInt(w.width);
index e7b6dfa..51dd9f5 100644 (file)
@@ -1,8 +1,11 @@
 public class Hello {
 
     public static void main(String[] args) {
+        // Création d'une fenêtre avec, en paramètres, son titre, sa
+        // largeur et sa hauteur
         DrawingWindow w = new DrawingWindow("Exemple 1", 640, 480);
 
+        // Affichage d'un court message au milieu de la fenêtre
         w.drawText(w.width / 2, w.height / 2, "Hello world!");
     }
 }
diff --git a/TODO b/TODO
index 63a3bb2..056fbb0 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-* Add comments to examples
 * Add draw/fillTriangle
 * Add set(Bg)Color with int
 * Add waitMousePress