亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

微信小程式開發(fā)文檔 / 微信小程序API 繪圖closePath(關(guān)閉一個路徑)

微信小程序API 繪圖closePath(關(guān)閉一個路徑)

closePath


定義

關(guān)閉一個路徑

Tip: 關(guān)閉路徑會連接起點和終點。

Tip: 如果關(guān)閉路徑后沒有調(diào)用 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()

201612241609529295.png

const ctx = wx.createCanvasContext('myCanvas')// begin pathctx.rect(10, 10, 100, 30)
ctx.closePath()// begin another pathctx.beginPath()
ctx.rect(10, 40, 100, 30)// only fill this rect, not in current pathctx.setFillStyle('blue')
ctx.fillRect(10, 70, 100, 30)

ctx.rect(10, 100, 100, 30)// it will fill current pathctx.setFillStyle('red')
ctx.fill()
ctx.draw()

201612241610011789.png