...
| Code Block |
|---|
void setup()
{
size(600,600); // def. fenstergroesse
randomSeed(millis()); // seed random
smooth(); // aktiviere antialiasing
strokeWeight(5); // linienbreite
stroke(0,0,0,150);
noLoop();
}
void draw()
{
background(255);
pushMatrix();
translate(width *.5,height - 20);
wurzel(7);
popMatrix();
}
void mousePressed()
{
redraw();
}
// funktion
void wurzel(int tiefe)
{
if(tiefe <= 0) // teste ob das ende erreicht worden ist
{
// zeichen blueten
pushStyle();
int clr = (int)random(100,255);
stroke(clr,0,0,190);
fill(clr,0,0,190);
ellipse(0,0,50,50);
popStyle();
return;
}
// zeichne zweige
int x;
int y;
int count = (int)random(1,8);
for(int i = 0; i < count;i++)
{
x = (int)random(-100,100);
y = -(int)random(10,150);
line(0,0,x,y);
pushMatrix();
translate(x,y);
scale(random(.3,.95));
wurzel(tiefe-1);
popMatrix();
}
} |
Aufgabe:
- Verändere das Beispiel, mach andere Äste, Blüten, etc…