Dokumentation zur WeChat-Applet-Entwicklung
/ 微信小程序API 繪圖closePath(關(guān)閉一個路徑)
微信小程序API 繪圖closePath(關(guān)閉一個路徑)
closePath
定義
關(guān)閉一個路徑
Tip: 關(guān)閉路徑會連接起點(diǎn)和終點(diǎ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()
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()