Draw Path in Canvas
<html>
<head>
<title>Draw Path in Canvas in HTML5</title>
</head>
<body>
<canvas id="mycanvas" width="600" height="300" style="border: 1px solid black;"></canvas>
<br>
<input type="button" value="Draw Path" onclick="drawPath()">
<script type="text/javascript">
function drawPath() {
var mycanvas = document.getElementById('mycanvas');
var ctx = mycanvas.getContext('2d');
// Line 1
ctx.moveTo(10, 10);
ctx.lineTo(100, 100);
// bezier curve
ctx.bezierCurveTo(290, -40, 300, 200, 400, 150);
// line 2
ctx.lineTo(500, 90);
ctx.lineWidth = 5;
ctx.strokeStyle = 'red';
ctx.stroke();
}
</script>
</body>
</html>
Run Application
Open site in browser and display as below: