canvas context coordinates - Javascript Canvas

Javascript examples for Canvas:Text

Description

canvas context coordinates

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.js"></script> 
      <style id="compiled-css" type="text/css">

#myCanvas{//w ww .j  a v  a 2  s.c om
   margin-left:auto;
   margin-right: auto;
   border:1px solid grey
}


      </style> 
      <script type="text/javascript">
    $(window).load(function(){
var canvas = $("#myCanvas");
    canvas[0].width = 700;
    canvas[0].height = 100;
var pen = canvas[0].getContext("2d");
pen.strokeStyle = "#000000";
pen.lineWidth = "2";
pen.beginPath();
pen.moveTo(700, 100);
pen.lineTo(0,0);
pen.stroke();
    });

      </script> 
   </head> 
   <body> 
      <canvas id="myCanvas"></canvas>  
   </body>
</html>

Related Tutorials