<canvas id="ctx" width="300" height="300" border="1"></canvas> <script type="text/javascript"> var canvas = document.getElementById("ctx"); var ctx = canvas.getContext("2d"); function resetCanvas(){ ctx.clearRect(0, 0, canvas.width, canvas.height); } var frameno = 0; var fps = 100; function sequence1() { setTimeout(function () { resetCanvas(); ctx.beginPath(); ctx.arc(150, 150, 20+frameno*3, 0, 2*Math.PI, true); ctx.stroke(); frameno = frameno + 1; /* RERUN */ if(frameno > 50){ frameno = 0; } sequence1(); }, fps); } sequence1(); </script> |