/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.Pm1tU5uIC27/rev.698
*
* authors:
* el-sonny
*
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "qeom007", created by [unnamed author] & Roger Allen
// http://studio.sketchpad.cc/sp/pad/view/ro.9jVqDRbbDJ4kv/rev.807
// Pressing Control-R will render this sketch.
// inspired by
// http://patakk.tumblr.com/post/83247102946
int wr_ptr = 0;
int FIFO_LEN = 80;
int WIDTH = 25;
int WIDTH_INC = 1.5;
PVector[] xys = new PVector[FIFO_LEN];
PVector[] dxdys = new PVector[FIFO_LEN];
float[] widths = new float[FIFO_LEN];
//fib numbers
int f0 = 0;
int f1 = 1;
int f2 = 1;
void setup() {
for(int i = 0; i < FIFO_LEN; i++) {
xys[i] = new PVector();
dxdys[i] = new PVector();
widths[i] = WIDTH * sin(Math.PI*i/(FIFO_LEN-1)) + WIDTH_INC;
}
size(530, 560);
smooth();
frameRate(60);
background(0);
}
void draw3(PVector xy, PVector dxdy, float w)
{
color color1 = color(random(55), random(255), random(55));
color color2 = color(random(255), random(55), random(55));
color color3 = color(random(55), random(55), random(255));
color color4 = color(random(55), random(255), random(55));
color color5 = color(random(255), random(55), random(55));
color color6 = color(random(55), random(55), random(255));
float x1 = xy.x;
float y1 = xy.y;
float x2 = 1.21*dxdy.x*(w-WIDTH_INC) + xy.x;
float y2 = 1.21*dxdy.y*(w-WIDTH_INC) + xy.y;
float x3 = 1.21*dxdy.y*(w-WIDTH_INC) + xy.x;
float y3 = 1.21*dxdy.x*(w-WIDTH_INC) + xy.y;
float x4 = -3.21*dxdy.y*(w-WIDTH_INC) + xy.x;
float y4 = 3.21*dxdy.x*(w-WIDTH_INC) + xy.y;
float x5 = 14.21*dxdy.x*(w-WIDTH_INC) + xy.x;
float y5 = -14.21*dxdy.y*(w-WIDTH_INC) + xy.y;
float x6 = x1 + 22;
float y6 = y1 + 22;
strokeWeight(1*(w/(WIDTH+WIDTH_INC)));
fill(color1);
ellipse(x1,y1,w,w);
fill(color2);
ellipse(x2,y2,w,w);
fill(color3);
ellipse(x3,y3,w,w);
fill(color4);
ellipse(x4,y4,w,w);
fill(color5);
ellipse(x5,y5,w,w);
fill(color6);
ellipse(x6,y6,w,w);
}
void draw() { // this is run repeatedly.
float ms = millis()/600;
background(0);
translate(262,255);
stroke(255);
xys[wr_ptr].x = 155*sin(2*ms);
xys[wr_ptr].y = 220*cos(1*ms);
dxdys[wr_ptr].x = sin(3.5*ms);
dxdys[wr_ptr].y = cos(3.5*ms);
wr_ptr = (wr_ptr+1)%FIFO_LEN;
for(int i = 0; i < FIFO_LEN; i++) {
rd_ptr = (wr_ptr+i)%FIFO_LEN;
draw3(xys[rd_ptr], dxdys[rd_ptr], widths[i]);
}
}
int nextFib()//fibonacci equation
{
int result = f2;
f0 = f1;
f1 = f2;
f2 = f0 + f1;
return result;
}