Sofia Enriquez: Arbol Recursivo
De Casiopea
Del Programa | Diseñ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. |
---|---|
Horas PUCV | * Las horas PUCV corresponden a periodos académicos de 35 minutos. |
float ramas; void setup() { size(500, 500); smooth(); background(color(#030801)); stroke (color(#F202AF)); // color tronco ramas= radians(2); translate(width /4,height); strokeWeight(20); // Dibuja una línea de 50 píxeles line(160,160,160,-50); strokeWeight(0); // Dibuja una línea de 100 píxeles line(160,160,160,-0); // Mueve la funcion arbol al final de la linea translate(100,-100); // Inicia la funcion arbol } void drawTree(float x, float y, float big, int levels) { pushMatrix(); { stroke (color(#89E337)); translate(x, y); strokeWeight (5); line(0, 0, 0, -big/2); // tronco stroke (color(#92F007)); line(0, -big/2, -big/2, -big); // brazo izquierdo stroke (color(#58F505)); line(0, -big/2, big/2, -big); // brazo derecho // recursividad if (levels > 0) { drawTree(-big/2, -big, big*1, levels - 4); // Y izquierda drawTree(big/2, -big, big*2, levels -7); // Y derecha } } popMatrix(); } void draw() { } void mouseReleased() { drawTree(mouseX, mouseY, 25, round(random(1, 10))); }