HTML Canvas - Dotted stroke around circle

前端 未结 5 1854
陌清茗
陌清茗 2021-01-02 17:06

I do know there is no native support for doing dotted stroke lines rendered on a canvas, but I have seen the clever ways people have been able to generate support for this.<

5条回答
  •  隐瞒了意图╮
    2021-01-02 17:48

    the simplest way using context.setLineDash()

    ctx.beginPath();
    ctx.setLineDash([5, 5]);
    ctx.beginPath();
    ctx.arc(100, 60, 50, 0, Math.PI * 2);
    ctx.closePath();
    ctx.stroke();
    

提交回复
热议问题