closePath : Returning to starting point on CanvasReturns to the starting point.
For this triangle two lines are drawn and then by closePath() the pointer has returned to starting point. With stroke() command the lines are actually drawn.
closePath() take the pointer to starting point
var my_canvas=$('#my_canvas').get(0) var gctx = my_canvas.getContext("2d"); var x=20; var y=20; gctx.clearRect(0, 0, my_canvas.width,my_canvas.height); gctx.beginPath() gctx.lineWidth=3; gctx.strokeStyle='#af46f5'; gctx.moveTo(x,y); gctx.lineTo(x+150,y+150); gctx.lineTo(x+300,y); gctx.closePath(); gctx.stroke();
This article is written by plus2net.com team.
|