Arbolitos

De Casiopea
{{{Título}}}



Título
Período2011-
AsignaturaImagen Escrita,
Del CursoImagen Escrita,
CarrerasArquitectura
Alumno(s)Giglia Schiappacasse García
ProfesorHerbert Spencer

void setup() {
  size(700, 300);
  smooth();
  background(255);
}
 
 
void drawTree(float x, float y, float big, int levels) {
  pushMatrix();
  {
    translate(x, y);
 
 
strokeWeight(4);
    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*0.3, levels - 1); // Y izquierda
      drawTree(big/2, -big, big*0.3, levels - 1);  // Y derecha
    }
  }
  popMatrix();
}
 
 
void draw() {
}
 
 
void mouseReleased() {
  drawTree(mouseX, mouseY, random(60, 300), round(random(3, 8)));
}