Permalink
Browse files

added sine test sketch

  • Loading branch information...
1 parent eb89acd commit 0f47a398c1d56a10d559a45c12bd69e060772352 @pixelpusher committed Jan 12, 2012
Showing with 35 additions and 0 deletions.
  1. +35 −0 SimpleSineDrawing/SimpleSineDrawing.pde
@@ -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.