WeChat アプレット開発ドキュメント
/ 微信小程序API 繪圖beginPath(開始一個(gè)路徑)
微信小程序API 繪圖beginPath(開始一個(gè)路徑)
beginPath
定義
開始創(chuàng)建一個(gè)路徑,需要調(diào)用fill或者stroke才會(huì)使用路徑進(jìn)行填充或描邊。
Tip: 在最開始的時(shí)候相當(dāng)于調(diào)用了一次 beginPath()
。
Tip: 同一個(gè)路徑內(nèi)的多次setFillStyle()
、setStrokeStyle()
、setLineWidth()
等設(shè)置,以最后一次設(shè)置為準(zhǔn)。
例子
const ctx = wx.createCanvasContext('myCanvas')// begin pathctx.rect(10, 10, 100, 30) ctx.setFillStyle('yellow') ctx.fill()// 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()