float theta = 0;
float amp = 10;
PVector base = new PVector(0,0);
float[] ys;
void setup()
{
size(800, 800);
ys = new float[600];
for(int i=0;i < ys.length;i++)
ys[i] = 0;
}
void draw()
{
background(255);
noFill();
stroke(0);
theta+=0.025;
base.set(0,0,0);
pushMatrix();
translate(150,300);
for(int i = 1;i < 21;i+=2)
do_line(base,i);
ys[0] = base.y;
for(int i = ys.length-1;i>0;i--)
{
ys[i] = ys[i-1];
}
stroke(100,0,0);
line(base.x,base.y,150,ys[0]);
stroke(0,0,120);
beginShape();
for(int x = 0; x < ys.length;x++)
{
vertex(x+150,ys[x]);
}
endShape();
popMatrix();
}
void do_line(PVector _base, float _i)
{
float y2 = 70*(sin(theta*_i) )/ (_i) +base.y;
float x2 = 70*(cos(theta*_i) )/ (_i) +base.x;
stroke(220);
ellipse(base.x,base.y,140/_i,140/_i);
stroke(0);
line(base.x,base.y,x2,y2);
base.x=x2;
base.y=y2;
}