Thursday, 17 October 2013

How To Draw On The Canvas With Javascript in HTML5 Example ?

All drawing on the canvas must be done inside JavaScript :-

Example-

  1. <HTML>
  2. <body>
  3.  
  4. <canvas id="canvas-ex" width="300" height="200" style="border:2px solid #A5A5A5;">
  5. THE CANVAS TAG
  6. </canvas>
  7.            
  8. <script>
  9. var i=document.getElementById("canvas-ex");
  10. var ctx=i.getContext("2D");
  11. ctx.fillStyle="#FF2200";
  12. ctx.fillRect(0,0,180,90);
  13. </script>

  14. </body>
  15. </HTML>

No comments:

Post a Comment