Line

To draw a line, we can use the beginPath(), moveTo(), lineTo(), and stroke() functions.

#

Functions:

lineJoin
#
lineCap
#

Properties:

Controlling stroke:

You can control the line joining with the property ctx.lineJoin which can be round, miter, and bevel. If you use miter (pointy corners) you can control how far the mitering sticks out on sharp corners by setting the value of ctx.miterLimit to the number of pixels that it should not go past.

You can also control the line ends with ctx.lineCap property which can have one of butt ,round, and square. Butt has a flat end that stops at the coordinates of the start and end of the line. Square adds half the line width to the start and end of the line.

To Do

Try the following options:

Change lineCap and lineJoin and see the result.