Marcelo Henríquez : Recursividad - árbol
De Casiopea
Título | Recursividad_árbol |
---|---|
Asignatura | Imagen Escrita, |
Del Curso | Taller Inicial 1ª y 2ª Etapa, |
Carreras | Arquitectura |
Alumno(s) | Marcelo Henríquez |
Profesor | Herbert Spencer |
void setup() { size(700, 500); smooth(); background(#59AEED); stroke(#15983D); } void drawTree(float x, float y, float big, int levels) { pushMatrix(); { translate(x, y); line(0, 0, 0, -big/2); // 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*.8, levels - 2); // Y izquierda drawTree(big/2, -big, big*0.8, levels - 1); // Y derecha } } popMatrix(); } void draw() { } void mouseReleased() { drawTree(mouseX, mouseY, random(20, 100), round(random(8, 10))); }