Paulina Mora: Árbol recursividad
De Casiopea
Archivo:Árbol recurs.png
Arbol recusividad
Título | Arbol recusividad |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Asignatura | Taller Inicial 1ª y 2ª Etapa, |
Del Curso | Imagen Escrita, |
Alumno(s) | Paulina Mora |
Profesor | Herbert Spencer |
void setup() {
size(500, 500); smooth(); background(#E3D5B0);
}
void drawTree(float x, float y, float nCircles, int levels) {
pushMatrix(); { float circleSize; float nLines;
// Dibuja el tronco for (int i=0; i<nCircles/5; i++) { // Tamaño de un circulo entre 20 y 40 circleSize = random(20, 40); // Colorea el circulo de colores entre {200-250, 60-200, 0} y de transparencia entre 100-150 fill(random(200, 250), random(60, 100), 0, random(100, 150)); // Dibuja el circulo en la posición {x,y} más variaciones aleatorias ellipse(x+random(-20, 20), y+random(80, 200), circleSize, circleSize); }
// Dibuja nCircles numero de hojas for (int i=0; i<nCircles; i++) { // Tamaño de un circulo entre 20 y 40 circleSize = random(20, 40); // Colorea el circulo de colores entre {120-170, 60-200, 0} y de transparencia entre 50-100 fill(random(120, 170), random(60, 200), 0, random(50, 100)); // Dibuja el circulo en la posición {x,y} más variaciones aleatorias ellipse(x+random(-100, 100), y+random(-100, 100), circleSize, circleSize); } // Dibuja nCircles numero de hojas más externas for (int i=0; i<nCircles; i++) { // Tamaño de un circulo entre 20 y 40 circleSize = random(20, 40); // Colorea el circulo de colores entre {50-100, 60-200, 0} y de transparencia entre 50-100 fill(random(50, 100), random(60, 200), 0, random(50, 100)); // Dibuja el circulo en la posición {x,y} más variaciones aleatorias ellipse(x+random(-130, 130), y+random(-130, 130), circleSize, circleSize); } // recursividad if (levels > 0) { drawTree(x+random(-15, 15), y+random(-15, 15), nCircles, levels - 1); } } popMatrix();
}
void draw() { }
void mouseReleased() {
drawTree(mouseX, mouseY, random(130, 180), 8); saveFrame("arbol.jpg");
}