Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body contenteditable="false">

<canvas id="myCanvas" width="100" height="100" style="border:1px solid #d3d3d3;">
Your browser does not support the canvas element.
</canvas>

<script>

var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");


ctx.beginPath();
ctx.moveTo(0,100);
ctx.lineTo(20,80);
ctx.lineTo(10,80);

</script>



</body>
</html>


What I have tried:

tried several points but unable to draw down line.
Posted
Updated 4-Oct-16 19:27pm

1 solution

use stroke()[^] to draw a line
JavaScript
ctx.lineTo(10, 80);
     ctx.stroke();
 
Share this answer
 
Comments
Nilesh_pat 5-Oct-16 3:26am    
Thank you sir.
Karthik_Mahalingam 5-Oct-16 3:31am    
cool, if it works, please close this post formally by clicking "Accept answer"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900