refresh the canvas after x seconds - Javascript Canvas Reference

Javascript examples for Canvas Reference:clearRect


refresh the canvas after x seconds

Demo Code

ResultView the demo in separate window

      <canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
          Your browser does not support the HTML5 canvas tag. 
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0,0,150,75);//w w  w  . j a v a  2s.c  om
  ctx.clearRect(0, 0, c.width, c.height);
  console.log("Canvas cleared");


Related Tutorials