X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/graphlib_java.git/blobdiff_plain/d9112cf5bc9cd4ee1b39a50c0154a5b219f66c7c..7f8d18f8d0b3b4a67e21b6b88e9e19db3c7f78d2:/Exemple2.java diff --git a/Exemple2.java b/Exemple2.java index 1cff9d9..3b3b1bc 100644 --- a/Exemple2.java +++ b/Exemple2.java @@ -1,12 +1,15 @@ import java.util.*; -public class Exemple2 { +class Exemple2 { public static void main(String[] args) { - DrawingWindow w = new DrawingWindow("Exemple 3", 640, 480); + // Création de la fenêtre + DrawingWindow w = new DrawingWindow("Exemple 2", 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); } }