I would like to draw some dashed lines on HTML5 canvas. But I couldn\'t find there is such a feature. the canvas path could only draw solid lines. And people have tried to u
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.setLineDash([5, 3]);/*dashes are 5px and spaces are 3px*/
ctx.beginPath();
ctx.moveTo(0,100);
ctx.lineTo(400, 100);
ctx.stroke();