title: Javascript and Canvas - Animating a Sine wave
body: <p>So, I have the following code to animate something upwards... it's very basic...</p>
  
  <pre><code>SetInterval(function() {
     particlesY -= 1;
  }, 10);
  </code></pre>
  
  <p>Then a loop as such:</p>
  
  <pre><code>ctx.clearRect(0,0,canvas.width,canvas.height);
  ctx.drawRect(50, particlesY, 32, 32);
  </code></pre>
  
  <p>This works fine, but I want a bit of X-Axis variation - I can use <code>Math.random()</code> to get a random direction, but the result is very jerky and pretty much laughable.</p>
  
  <p>I figured that a sine wave would give me a nice smooth X-Axis change.</p>
  
  <p>Any ideas? :(</p>