WeChat applet development documentation
/ 微信小程序save/restore(保存和恢復(fù)繪圖上下文)
微信小程序save/restore(保存和恢復(fù)繪圖上下文)
save
定義
保存當(dāng)前的繪圖上下文。
restore
定義
恢復(fù)之前保存的繪圖上下文。
例子
const ctx = wx.createCanvasContext('myCanvas')// save the default fill stylectx.save() ctx.setFillStyle('red') ctx.fillRect(10, 10, 150, 100)// restore to the previous saved statectx.restore() ctx.fillRect(50, 50, 150, 100) ctx.draw()