关闭一个路径
tip: 关闭路径会连接起点和终点。
tip: 如果关闭路径后没有调用fill()
或者stroke()
并开启了新的路径,那之前的路径将不会被渲染。
const ctx = wx.createcanvascontext('mycanvas')
ctx.moveto(10, 10)
ctx.lineto(100, 10)
ctx.lineto(100, 100)
ctx.closepath()
ctx.stroke()
ctx.draw()
const ctx = wx.createcanvascontext('mycanvas')
// begin path
ctx.rect(10, 10, 100, 30)
ctx.closepath()
// begin another path
ctx.beginpath()
ctx.rect(10, 40, 100, 30)
// only fill this rect, not in current path
ctx.setfillstyle('blue')
ctx.fillrect(10, 70, 100, 30)
ctx.rect(10, 100, 100, 30)
// it will fill current path
ctx.setfillstyle('red')
ctx.fill()
ctx.draw()