sinWave 10 lines
clair chin
10 lines moving along sin wave with amplitude according to mouse X
<pre lang="java" line="1">
int startingX;
int increment;
float x;
float pi;
void setup()
{
size(800,300);
increment=width/11;
x=0;
pi=3.141592654;
}
void draw()
{
background(0);
println(x<2*pi);
if (x<2*pi)
{
x=x+(2*(pi/100));
}
else
{
x=0;
}
float waveLevel=map(mouseX,0,width,0,70);
for (int i=1;i<11;i++)
{
stroke(255);
float shift = sin(x+i*2*pi/10)*waveLevel;
line((increment*i),140+shift,(increment*i),155+shift);
}
}
</pre>