当前位置:K88软件开发文章中心编程语言Html5Html501 → 文章内容

html5 canvas 画虚线的方法

减小字体 增大字体 作者:wangsdong     来源:asp编程网  发布时间:2018-12-30 8:42:04

<
canvas id="mycanvas" width="520" height="400" style="border: 0px solid
#000
background-color:
#fff
">
<
/canvas>

<
script>

mycanvas=document.getElementById("mycanvas")

ctx = mycanvas.getContext("2d")

//画线

ctx.beginPath()
 

ctx.setLineDash([3, 3])
 
//画虚线

ctx.moveTo(100,100)

ctx.lineTo(200,100)

ctx.stroke()

ctx.closePath()

<
/script>


html5 canvas 画虚线的方法