Swing on the spiral Juan Hernandez
De Casiopea
Título | Fibonacci Juan Hernandez |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 11 |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Juan Alejandro Hernández |
// espiral de fibonacci por juan hernandez :) void setup() { size(600, 600); smooth(); background(255); strokeWeight(0); fibonacci(500); } void fibonacci(int iterations) { int r = 2; // rango rojo 0 - 255 int v = 10; // rango verde 0 - 255 int c = 25; // rango azul 0 - 255 stroke(1, 255); int posx = width/2; int posy = height/2; int fibant = 1; int fibnew = 0; for (int fib = 1; fib < iterations;) { for (int a = 0; a < 4; a++) { fibnew = fib + fibant; fibant = fib; fib = fibnew; r = r + 7; v = v + 1; c = c/2 + 5; fill(r, v, c); // el cambio de este arreglo delimita el color del fondo de la espiral siendo r=rojo v=verde y c=azul strokeWeight(0); // delgado rect(posx, posy, fib, fib); if (a == 0) { strokeWeight(2); // grueso arc(posx + fib, posy + fib, fib*2, fib*2, PI, TWO_PI-PI/2); posx = posx + fib; } else if (a == 1) { strokeWeight(2); // grueso arc(posx, posy + fib, fib*2, fib*2, TWO_PI-PI/2, TWO_PI); posx = posx - fibant; posy = posy + fib; } else if (a == 2) { strokeWeight(2); // grueso arc(posx, posy, fib*2, fib*2, 0, PI/2); posx = posx - fib - fibant; posy = posy - fibant; } else if (a == 3) { strokeWeight(2); // grueso arc(posx + fib, posy, fib*2, fib*2, PI/2, PI); posy = posy - fib - fibant; } } } }