Set the line dash pattern

ctx.lineWidth = ;

ctx.lineCap = ;

ctx.setLineDash([, , , , , ]);

ctx.beginPath();

ctx.moveTo(, );

ctx.lineTo(, );

ctx.lineTo(, );

ctx.lineTo(, );

ctx.stroke();

Show the path

Number of lengths in the array:

Change the array passed to the setLineDash() function to see how this affects how the path is drawn on the <canvas>. Use the number field at the bottom to change the number lengths in the array.