HTML Canvas Spiral
<html> <head> <script> window.onload = function(){ var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); //from ww w . j a v a 2 s . c o m var radius = 0; var angle = 0; context.lineWidth = 15; context.strokeStyle = "black"; context.beginPath(); context.moveTo(canvas.width / 2, canvas.height / 2); for (var n = 0; n < 350; n++) { radius += 0.85; // make a complete circle every 50 iterations angle += (Math.PI * 2) / 50; var x = canvas.width / 2 + radius * Math.cos(angle); var y = canvas.height / 2 + radius * Math.sin(angle); context.lineTo(x, y); } context.stroke(); }; </script> </head> <body> <canvas id="myCanvas" style="border:1px solid black;"> </canvas> </body> </html>