Set canvas line width, stroke style and draw rectangle - Javascript Canvas

Javascript examples for Canvas:Line

Description

Set canvas line width, stroke style and draw rectangle

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*www.ja v  a  2 s.co  m*/
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.strokeStyle = "#CCCC00";
ctx.lineWidth = 15;
ctx.strokeRect(0, 0, 300, 100);
    });

      </script> 
   </head> 
   <body>
       uhhh... 
      <canvas id="canvas"></canvas>  
   </body>
</html>

Related Tutorials