画出当前路径的边框。默认颜色色为黑色。
tip:stroke()
描绘的的路径是从beginpath()
开始计算,但是不会将strokerect()
包含进去,详情见例二。
const ctx = wx.createcanvascontext('mycanvas')
ctx.moveto(10, 10)
ctx.lineto(100, 10)
ctx.lineto(100, 100)
ctx.stroke()
ctx.draw()
const ctx = wx.createcanvascontext('mycanvas')
// begin path
ctx.rect(10, 10, 100, 30)
ctx.setstrokestyle('yellow')
ctx.stroke()
// begin another path
ctx.beginpath()
ctx.rect(10, 40, 100, 30)
// only stoke this rect, not in current path
ctx.setstrokestyle('blue')
ctx.strokerect(10, 70, 100, 30)
ctx.rect(10, 100, 100, 30)
// it will stroke current path
ctx.setstrokestyle('red')
ctx.stroke()
ctx.draw()