微信小程序save/restore(保存和恢復(fù)繪圖上下文)

2022-05-09 17:00 更新

微信小程序 canvas接口和方法繪圖接口和方法

canvasContext.save


定義

保存當(dāng)前的繪圖上下文。

restore


定義

恢復(fù)之前保存的繪圖上下文。

例子

const ctx = wx.createCanvasContext('myCanvas')

// save the default fill style
ctx.save() 
ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 100)

// restore to the previous saved state
ctx.restore()
ctx.fillRect(50, 50, 150, 100)

ctx.draw()


微信小程序 canvas接口和方法繪圖接口和方法

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號