Árbol recursividad
De Casiopea
Título | Magdalena Friedrichs: Árbol Recursividad |
---|---|
Asignatura | Imagen Escrita, |
Del Curso | Imagen Escrita, |
Carreras | Arquitectura |
Alumno(s) | Magdalena Friedrichs Lagos |
Profesor | Herbert Spencer |
void setup() { size(400, 600); smooth(); background(220,223,204); } void drawTree(float x, float y, float big, int levels) { pushMatrix(); { translate(x, y); 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 line(0, 0, 0, -big/2); // tronco if (levels > 0) { stroke(56,37,33); //color hojas drawTree(-big/2, -big, big*(random(.5, 1)), levels - 1); // Y izquierda drawTree(big/2, -big, big*.2, levels - 1); // Y derecha // color ramas drawTree(0, -big*(random(.5, 1)), big*0.8, levels - 1 ); // rama central } } popMatrix(); } void draw() { } void mouseReleased() { drawTree(mouseX, mouseY, 100, round(9)); //hace la recursiva saveFrame("árbol crema/cafe.jpg"); }