Catalina Correa: Recursividad árbol

De Casiopea
Catalina Correa : Recursividad arbol morado



TítuloCatalina Correa : Recursividad arbol morado
AsignaturaImagen Escrita,
Del CursoImagen Escrita,
CarrerasDiseño Industrial"Diseño Industrial" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property.
Alumno(s)Catalina Correa

<code:>

 void setup() {
 size(500, 600);
 smooth();
  background(#ded5e5);
 }


 void drawTree(float x, float y, float big, int levels) {
 pushMatrix();
 {
   translate(x, y);
   line(0, -big/3, -big/3, -big); // brazo izquierdo
   line(0, -big/3, 0, -big);         // brazo central
   line(0, -big/3, big/3, -big);  // brazo derecho
   line(0, 0, 0, -big/3);         // tronco
   if (levels > 0) {
     stroke(random (1, 170) , 0, random (1, 240 ));                            //color hojas
     drawTree(-big/2, -big, big*(random(.5, 1)), levels - 1); // Y izquierda
     drawTree(big/2, -big, big*(random(.5, 1)), levels - 1);  // Y derecha
     stroke(random (1, 170), 0, random(1, 237));                           // color ramas
     drawTree(0, -big*(random(.5, 1)), big*0.8, levels - 1 );     // rama central
   }
  }
  popMatrix();
 }
 void drawTronco(float x, float y, float x1, float y1) {     // Linea para el tronco
 strokeWeight(4);
 {
   stroke(#AA60ED);
   line(x, y, x1, y1);
 }
 }
 void draw() { 
 }
 void mouseReleased() {
 drawTree(mouseX, mouseY, 100, round(9));            //hace la recursiva
 drawTronco(mouseX, mouseY, mouseX, mouseY-90);      // Dibuja la linea del troncoç
 saveFrame("arbolitocata.jpg");
 }

</code:>