Skip to content

Commit

Permalink
added sine test sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelpusher committed Jan 12, 2012
1 parent eb89acd commit 0f47a39
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions SimpleSineDrawing/SimpleSineDrawing.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
int speed = 2; // how fast it scrolls across the screen (0 is not moving)
float periods = 3; // how many humps the sine wave has
float waveHeight; // the height of the wave

void setup()
{
size(512,256);
background(0);

waveHeight = height/2;
}


void draw()
{
//periods = map(mouseX, 0,width, 1, 20);

//waveHeight = height/2 * sin(frameCount/20);

background(0);
fill(255);
stroke(255);

for (int index=0; index < width; index++)
{
int movedIndex = index + (frameCount*speed);
movedIndex = movedIndex % width; // wrap around width

float heightValue = waveHeight *
sin( map(movedIndex, 0,width, 0, periods*TWO_PI) )
+ waveHeight;

point(index, heightValue);
}
}

0 comments on commit 0f47a39

Please sign in to comment.