/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.odhT6zZbeFp/rev.807
*
* authors:
*
* Roger Allen
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// 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];
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(330, 460);
smooth();
frameRate(30);
}
void draw3(PVector xy, PVector dxdy, float w)
{
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;
strokeWeight(1.5*(w/(WIDTH+WIDTH_INC)));
fill(230);
ellipse(x1,y1,w,w);
fill(210);
ellipse(x2,y2,w,w);
fill(180);
ellipse(x3,y3,w,w);
}
void draw() { // this is run repeatedly.
float ms = millis()/600;
background(230);
stroke(0);
translate(165,225);
xys[wr_ptr].x = 75*sin(2*ms);
xys[wr_ptr].y = 150*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]);
}
}