Título | Arbol recursividad Felipe Aranda |
---|---|
Tipo de Proyecto | Proyecto de Taller |
Asignatura | Imagen Escrita, |
Del Curso | Imagen Escrita, |
Carreras | Arquitectura |
Alumno(s) | Felipe Aranda |
Profesor | Herbert Spencer |
void setup() {
size(700, 500);
smooth();
background(255);
}
void drawTree(float x, float y, float big, int levels) {
pushMatrix();
{
translate (x,y);
line(0, 0, 0, -big); // tronco
line(0, -big/2, -big/2, -big); // brazo izquierdo
line(0, -big/2, big/2, -big); // brazo derecho
// recursividad
if (levels > 0) {
drawTree(-big/2, -big, big*0.5, levels - 1); // Y izquierda
drawTree(big/2, -big, big*0.5, levels -4); // Y derecha
}
}
popMatrix();
}
void draw() {
strokeWeight(1); // Thicker
stroke(106 , 111, 27); saveFrame("ARBOL.jpg");
}
void mouseReleased() {
drawTree(mouseX, mouseY, random(10, 100), round(random(3, 6)));
}