sine wave 2
by marakoss
HTML
<canvas id="myCanvas" width="360" height="360" style="border:1px solid #d3d3d3;">
JavaScript
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var i;
/*for(i=0; i<360; i+= 20){
//ctx.moveTo(i+5,180);
//ctx.lineTo(i,180);
}*/
ctx.stroke();
var counter = 0, x=0,y=0;
//100 iterations
//var increase = 90/180*Math.PI / 9;
for(i=0; i<=360; i+=1){
//ctx.moveTo(x,y);
x = i;
y = 180 - Math.sin(i/49) * 50;
//counter += 1;
//ctx.lineTo(x,y);
ctx.fillRect(x, y, 1, 1);
ctx.stroke();
//alert( " x : " + x + " y : " + y + " increase : " + counter ) ;
}