Constanza Johnson: Tarea árbol

De Casiopea
Foto Árbol




TítuloFoto Árbol
Del CursoImagen Escrita,
CarrerasDiseño Gráfico"Diseño Gráfico" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property., Diseñ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)Constanza Johnson
ProfesorHerbert Spencer
void setup() {
  size(700, 500);
  smooth();
  background(204,229,93);
}

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, big/2, -big);  // brazo derecho
    stroke(116,79,30);

    // recursividad
    if (levels > 0) {
      drawTree(-big/2, -big, big*0.8, levels - 2); // Y izquierda
      drawTree(big/2, -big, big*0.8, levels - 2);  // Y derecha
    }
  }
  popMatrix();
}

void draw() {
}

void mouseReleased() {
  drawTree(mouseX, mouseY, random(20, 80), round(random(2, 4)));
}