/*************************************************************************\ * JOURNEE DU LIBRE - AFFICHE sous licence GPLv3 * * * * COPYRIGHT: (C) 2008 Juego (aka Julien Deswaef) * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see http://www.gnu.org/licenses/ * * * * HOWTO: * * - Telechargez Processing sur processing.org et installez-le. * * - Recopiez ce code dans la fenetre principale. * * - Utilisez le menu "Tools > Create Font..." pour creer 1 police * * de taille 30 nommees "code" * * - Sauvez le sketch sous le nom: "BxLUG_flower_WebApplet" * * - Tappez CTRL+R * * * * CONTACT: juego [at] requiem4tv . com * * INFO: XUV.be * \*************************************************************************/ /* GLOBAL VARIABLES ***/ Petal pet; float petallong; // taille de la petale en rapport avec la taille de l'écran. PFont code; // la police pour afficher le code /* INIT ***/ void setup() { // Différentes tailles en fonction de la sortie: //size(3508, 4960); // A3 @300dpi //size(2480, 3508); // A4 @300dpi //size(1754, 2480); // A5 @300dpi size(600, 800); // Web Applet background(255); petallong = 3.5*min(width,height)/16; pet = new Petal(3, petallong/10, petallong, color(255)); smooth(); noLoop(); randomSeed(0); stroke(255, 50); // contour blanc tranparent. code = loadFont("code.vlw"); } /* CORE ***/ void draw() { background(255); // fond blanc float[] col = { 0.0, 300.0}; pet.corolle(width/2, height/2, 250, col, 30, 255, 100); pet.longueur = 3*petallong/4; col[1] = 150.0; noStroke(); // supprimer le contour pet.corolle(width/2, height/2, 250, col, 200, 255, 80); pet.longueur = 2*petallong/5; col[1] = 55.0; pet.corolle(width/2, height/2, 250, col, 255, 255, 60); montrerCode(); //save("BxLUG_Flower_color_A5.tif"); // sauve le fichier //exit(); } /* FUNCTIONS ***/ //Affichage du code sur l'image void montrerCode() { String lines[] = loadStrings("BxLUG_Flower_WebApplet.pde"); fill(0); float typeheight = (4*height/5)/lines.length; print(typeheight); textFont(code, typeheight); for (int i=0; i < lines.length; i++) { text(lines[i], width/20, (height/10)+(i+1)*typeheight); } } /* CLASSES ***/ class Petal { int nbPoints, nbPetales; // nombre de points a calculer pour les petales float largeur, longueur; // largeur et longueur d'une pétale color couleur; // Couleur de la pétale float[] coordX, coordY; //coordonnées en X et Y des points de la petale float centerx, centery; // centre de la fleur float[] colorRange = new float[2]; // portion du cercle chromatique float angle; // angle de dispersion des petales int satur = 255; // saturation int bright = 255; // luminosite int transp = 255; // transparence // constructeur Petal(int nb, float lar, float lon, color coul) { largeur = lar; longueur = lon; couleur = coul; nbPoints = nb; coordX = new float[nbPoints]; coordY = new float[nbPoints]; this.scramble(); } // dessine la petale void dessine(){ fill(couleur); pushMatrix(); beginShape(); vertex(0,0); for(int i=0; i