HTML canvas lineCap property
Examples
Draw the circle line of the end cap:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineCap="round";
ctx.moveTo(20,20);
ctx.lineTo(20,200);
ctx.stroke();
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineCap="round";
ctx.moveTo(20,20);
ctx.lineTo(20,200);
ctx.stroke();
try it"
Browser Support
Internet Explorer 9, Firefox, Opera, Chrome and Safari support lineCap property.
Note: 8 and earlier versions of Internet Explorer do not support the <canvas> element.
Definition and Usage
lineCap property sets or returns the line end of the line cap style.
Note: "round" and "square" value makes the lines a little longer.
Defaults: | butt |
---|---|
JavaScript syntax: | context .lineCap = "butt | round |square"; |
Property Value
值 | 描述 |
---|---|
butt | 默认。向线条的每个末端添加平直的边缘。 |
round | 向线条的每个末端添加圆形线帽。 |
square | 向线条的每个末端添加正方形线帽。 |
HTML canvas Reference Manual