float amplitude = 200;
float xStep = 0.1;
float currentAngle = 0.0;
float angleSpeed = 0.5;
float angleStep = 2.0*PI / 512;
void setup(){
size(500, 500);
smooth();
noFill();
background(0);
frameRate(60);
}
void draw(){
background(0);
stroke(255);
strokeWeight(1);
float angle = currentAngle;
float y = amplitude * sin(angle) + (height / 2);
float x = 0.0;
while(x <= width){
angle += angleStep;
float nextX = x + xStep;
float nextY = amplitude * sin(angle) + (height / 2);
line(x, y, nextX, nextY);
x = nextX;
y = nextY;
}
updateCurrentAngle();
}
void updateCurrentAngle(){
currentAngle += angleSpeed;
if(currentAngle >= 2*PI){
currentAngle -= 2 *PI;
}
}