WeChat applet save/restore (save and restore drawing context)


save


Definition

Save the current drawing context.

restore


Definition

Restore the previously saved drawing context.

Example

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()

201612261809427113.png