X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML canvas lineCap Property

Canvas Object Reference Canvas Object

Example

Draw a line with rounded end caps:

YourbrowserdoesnotsupporttheHTML5canvastag.

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();

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the lineCap property.

Note: Internet Explorer 8 and earlier versions, do not support the <canvas> element.


Definition and Usage

The lineCap property sets or returns the style of the end caps for a line.

Note: The value "round" and "square" make the lines slightly longer.

Default value: butt
JavaScript syntax: context.lineCap="butt|round|square";

Property Values

Value Description Play it
butt Default. A flat edge is added to each end of the line Play it »
round A rounded end cap is added to each end of the line Play it »
square A square end cap is added to each end of the line Play it »


Canvas Object Reference Canvas Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook