Draw line in HTML Canvas : In this article i will show you how we can draw line in HTML canvas. To draw line in HTML we will use Canvas API, we will draw the line on canvas using the lineTo() method. Following is the simple example to draw line on canvas:
Draw_line.html
<!DOCTYPE html>
<html>
<body>
<canvas id="lineCanvas" width="300" height="200" style="border:1px solid;"></canvas>
<script type="text/javascript">
var c = document.getElementById("lineCanvas");
var ctx = c.getContext("2d");
ctx.moveTo(5,5);
ctx.lineTo(250,150);
ctx.stroke();
</script>
</body>
</html>
0 Comment(s)