Catalina Ruff: Árbol

De Casiopea
Arbol recursividad Felipe Aranda



TítuloArbol recursividad Felipe Aranda
Tipo de ProyectoProyecto de Taller
AsignaturaImagen Escrita,
Del CursoImagen Escrita,
CarrerasArquitectura
Alumno(s)Felipe Aranda
ProfesorHerbert 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)));


}