/**
*
JDLFlowers_2009
* A graphic tool to create an illustration for a poster announcing the "journees du libre 2009".
* How to use:
* Click, hold, drag and release to draw a flower.
* Flower size is determined by the dragging distance.
* Flower color is determined by its position.
* Reload the page to start over.
*
* © Juego - Licence: GNU General Public Licence
*/
float _size = 60;
float dx, dy, px, py;
color couleur;
color blanc = #FFFFFF;
void setup() {
size(640,480);
background(255);
smooth();
colorMode(HSB, 100);
}
void draw() {
}
void mousePressed(){
dx = mouseX;
dy = mouseY;
}
void mouseReleased(){
px = mouseX;
py = mouseY;
float dd = dist(dx, dy, px, py);
//couleur = color( random(100), 100,50);
couleur = color( map( mouseX, 0, width, 5, 60), 100, 100);
tige(px, py, dd, width/2, height, couleur );
flower(px, py, dd, int(random(6)+1), couleur );
}
void flower(float px, float py, float _size, int nb_branches, color c) {
pushMatrix();
translate(px, py);
rotate(random(PI));
noStroke();
ellipseMode(CENTER);
fill(c);
ellipse(0, 0, _size, _size);
fill(blanc);
ellipse(0, 0, _size*0.9, _size*0.9);
fill(c);
rectMode(CENTER);
float ang = PI/nb_branches;
for(int i=0; i