topical media & game development

talk show tell print

graphic-canvas-example-draw-square.htm / htm



  <script type=text/javascript>
  function draw() {
    var ctx = document.getElementById('canvas').getContext('2d');
    for (i=0;i<6;i++){
      for (j=0;j<6;j++){
        ctx.fillStyle = 'rgb(' + Math.floor(255-42.5*i) + ',' + 
                         Math.floor(255-42.5*j) + ',0)';
        ctx.fillRect(j*25,i*25,25,25);
      }
    }
  }
  </script>
  <body onload="draw();">
  <canvas id="canvas" width="200" height="200"></canvas>
  


(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.