HTML canvas lineCap attribute
Definition and Usage
lineCap
Property setting or returning the style of the line end cap.
Note:"round
" and "square
" will make the line slightly longer.
Example
Drawing the end cap of the circular line:
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();
Syntax
context.lineCap="butt|round|square";
Attribute Value
Value | Description |
---|---|
butt | Default. Add straight edges to each end of the line. |
round | Add round caps to each end of the line. |
square | Add square caps to each end of the line. |
Technical Details
Default Value: | butt |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.