window.onload=function(){
ctx.beginPath();
ctx.setLineDash([]);//设定实线与空白的大小
ctx.moveTo(50,100);
ctx.lineTo(250,100);
ctx.stroke();
ctx.beginPath();
ctx.setLineDash([4]);//设定实线与空白的大小
ctx.moveTo(50,120);
ctx.lineTo(250,120);
ctx.stroke();
ctx.beginPath();
ctx.setLineDash([4,2]);//设定实线与空白的大小
ctx.moveTo(50,140);
ctx.lineTo(250,140);
ctx.stroke();
ctx.beginPath();
ctx.setLineDash([10,3,1]);//设定实线与空白的大小
ctx.moveTo(50,160);
ctx.lineTo(250,160);
ctx.stroke();
ctx.beginPath();
ctx.setLineDash([10,3,3,3,3]);//设定实线与空白的大小
ctx.moveTo(50,180);
ctx.lineTo(250,180);
ctx.stroke();
}
canvas绘制虚线setLineDash
猜你喜欢
转载自blog.csdn.net/dkm123456/article/details/112681395
今日推荐
周排行