HTML5 canvas closePath() 方法

实例

字母 L开始点:

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20,20);
ctx.lineTo(20,100);
ctx.lineTo(70,100);
ctx.closePath();
ctx.stroke();

Internet Explorer 9、Firefox、Opera、Chrome 以及 Safari 支持 closePath() 方法。

注释:Internet Explorer 8 <canvas> 元素。

closePath() 。

提示:请使用 stroke() 的路径。

提示:请使用 fill() 请使用 fillStyle /渐变。

JavaScript 语法:

context.closePath();

更多实例

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20,20);
ctx.lineTo(20,100);
ctx.lineTo(70,100);
ctx.closePath();
ctx.stroke();
ctx.fillStyle="green";
ctx.fill();