ctx.setLineDash([4, 16]); ctx.lineDashOffset = 2; ctx.beginPath(); ctx.moveTo(0,100); ctx.lineTo(400, 100); ctx.stroke();