Recursividad

De Casiopea



TítuloEl Arbolero
AsignaturaImagen Escrita 2017
Del CursoImagen Escrita 2017
CarrerasArquitectura
Alumno(s)Nicolas Farias


<processingjs> float theta;

void setup() {

 size(900, 900);

}

void draw() {

 background(255);
 frameRate(30);
 stroke(#16A773);
 strokeWeight(2);
 float a = (mouseX / (float) width) * 80f;
 theta = radians(a);
 translate(width/2,height/2);
 line(0,0,0, 450);
 translate(0, 0);
 branch(180);

}

void branch(float h) {

 h *= 0.68;
 
 if (h > 1.8) {
   pushMatrix();    
   rotate(theta);  
   line(0, 0, 0, -h);  
   translate(0, -h);
   branch(h);     
   popMatrix();  
   
   pushMatrix();
   rotate(-theta);
   line(0, 0, 0, -h);
   translate(0, -h);
   branch(h);
   popMatrix();
 }

} <processingjs>