Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1cff9d9c8e098a914995e78d651aa04035d1f0aa
[graphlib_java.git] / Exemple2.java
1 import java.util.*;
2
3 public class Exemple2 {
4
5     public static void main(String[] args) {
6         DrawingWindow w = new DrawingWindow("Exemple 3", 640, 480);
7
8         int width = Math.min(w.width - 1, w.height - 1) / 2;
9
10         for (int z = 0; z <= width; z++) {
11             float r, g, b;
12             float s = 3.0f * z / width;
13             if (z <= width / 3.0f) {
14                 r = 1.0f - s;
15                 g = s;
16                 b = 0.0f;
17             } else if (z <= 2.0f * width / 3.0f) {
18                 s -= 1.0f;
19                 r = 0.0f;
20                 g = 1.0f - s;
21                 b = s;
22             } else {
23                 s -= 2.0f;
24                 r = s;
25                 g = 0.0f;
26                 b = 1.0f - s;
27             }
28             w.setColor(r, g, b);
29             w.drawRect(z, z, w.width - 1 - z, w.height - 1 - z);
30         }
31     }
32 }