Triangle is composed of three lines, but we need only ctx.lineTo () twice, because, ctx.closePath () will be connected together to the starting point of the path is as follows:
function Draw () { var Canvas = document.getElementById ( 'canv' ); IF (canvas.getContext!) return ; var CTX = canvas.getContext ( "2D" ); // open path drawing ctx.beginPath (); / / determining a path starting point ctx.moveTo (30, 30 ); // draw a path ctx.lineTo (280, 280 ); // draw a path ctx.lineTo (280, 30 ); // end path drawn with ctx.beginPath ( ) connected ctx.closePath (); // stroke, or "presentation" ctx.stroke () } Draw ();