Sebastián Gallardo: Árbol Recursividad
De Casiopea
Título | |
---|---|
Asignatura | Taller Inicial 1ª y 2ª Etapa, |
Del Curso | Imagen Escrita, |
Carreras | Arquitectura |
Alumno(s) | Sebastián Gallardo |
Profesor | Herbert Spencer |
void setup() { size(500, 1000); smooth(); background(color(#C3ED62)); } 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,0,-big); // brazo central line(0, -big/2, big/2, -big); // brazo derecho // recursividad if (levels > 0) { stroke(0,random(50,250),0); drawTree(-big/2, -big, big*(random(.5,1)), levels - 1); // Y izquierda drawTree(big/2, -big, big*(random(.5,1)), levels - 1); // Y derecha drawTree(0, -big,big*(random(.5,1)), levels - 1 ); // rama central } } popMatrix(); } void draw() { } void mouseReleased() { drawTree(mouseX, mouseY, 100, round(9)); saveFrame("arbolrecursividadsg.jpg"); }