HTML Canvas fillRect() draw rectangle

Description

HTML Canvas fillRect() draw rectangle

View in separate window

<!DOCTYPE html>
<html>
  <head>
    <title>Learning the basics of canvas</title>
    <meta charset="utf-8">
    //from   ww w. ja v  a 2  s .  co  m
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    
    <script type="text/javascript">
      $(document).ready(function() {  
        var canvas = $("#myCanvas");
        var context = canvas.get(0).getContext("2d");
        
        context.fillRect(40, 40, 100, 100);
      });
    </script>
  </head>
  
  <body>
    <canvas id="myCanvas" width="500" height="500">
      <!-- Insert fallback content here -->
    </canvas>
  </body>
</html>



PreviousNext

Related