Write the javascript part in the head section of the html page.
<script> function Draw_Line(Canvas, Left_Position, Top_Position, Width, Height, Line_Color, LINE_WIDTH) { var Context2d = Canvas.getContext('2d'); Context2d.beginPath(); Context2d.moveTo(Left_Position, Top_Position); Context2d.lineTo(Width, Height); Context2d.lineWidth = LINE_WIDTH; // set line color Context2d.strokeStyle = Line_Color; Context2d.stroke(); } </script>
Write the html part in the body section of the html page.
<canvas id='myCanvas' width='500' height='500'></canvas> <script>Draw_Line(myCanvas, 200, 20, 20, 20, '#000000', 5);</script>