HTML Canvas beginPath() cubic Bezier curve

Description

HTML Canvas beginPath() cubic Bezier curve

View in separate window

<!DOCTYPE html>

<html>
  <head>
    <title>Pushing canvas further</title>
    <meta charset="utf-8">
    /*from w  w  w  . j av a  2 s .c o  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");
        
        // A cubic Bezier curve
        context.lineWidth = 5;
        context.beginPath();
        context.moveTo(50, 250);
        context.bezierCurveTo(150, 50, 350, 450, 450, 250);
        context.stroke();
        
      });
    </script>
  </head>
  
  <body>
    <canvas id="myCanvas" width="500" height="500">
      <!-- Insert fallback content here -->
    </canvas>
  </body>
</html>

      



PreviousNext

Related