topical media & game development

talk show tell print

sample-js-canvas.cfg / cfg



  <head>
  <script type="text/javascript">
    function addBox() {
      animatedctx.beginPath();
      if (Math.random()>0.99) animatedctx.clearRect(0,0,500,100); // randomly clear the screen with low probability
      animatedctx.fillStyle='rgba('+Math.round(Math.random()*255)+','+Math.round(Math.random()*255)+','+Math.round(Math.random()*255)+','+Math.round(Math.random()*255)+')';
      animatedctx.rect(Math.random()*500,Math.random()*100,Math.random()*100, Math.random()*100 );
      animatedctx.fill();
      setTimeout('addBox()', 50 );
    }
  </script>
  </head>
  <body>
  <canvas id="animated" width="500" height="100"> </canvas>
  <script>
  var animatedctx = document.getElementById('animated').getContext('2d');
  addBox();
  </script>
  </body>
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.