Sine wave display
JavaScript code
<body>
<canvas id="canvas" height="201" width="360"></canvas>
<script>
window.onload = function() {
var factor = Math.PI * 2 / 360.0;
var g = document.getElementById('canvas').getContext('2d');
g.fillStyle = "#ffff00";
g.fillRect(0, 0, 360, 201);
g.fillStyle = "#00ffff";
for (var x=0; x<360; x++) {
var y = Math.round(Math.sin(x * factor) * -100 + 100);
g.fillRect(x, y, 1, 1);
}
g.fillStyle = "#000000";
g.beginPath();
g.moveTo(0, 100);
g.lineTo(359, 100);
g.stroke();
}
</script>
</body>