# CanvasContext.draw(boolean reserve, function callback)

with Promise style call: Not supported

Mini Program plugin: Support

Draws a description (path, deformation, style) previously in the drawing context to canvas In.

# parameter

# boolean reserve

Whether this drawing follows the previous drawing. namely reserve Parameter is False, before this call is drawn native The layer will empty the canvas and continue drawingif reserve Parameter is True, the contents of the current canvas are retained, and this call drawCanvas Overwrites the drawing, default false。

# function callback

A callback function that executes after drawing is complete

# sample code

the second time draw() reserve for true。 So the result of the last drawing is preserved, and the fillStyle 'red' Has become the default. 'black'。

const ctx = wx.createCanvasContext('myCanvas')

ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 100)
ctx.draw()
ctx.fillRect(50, 50, 150, 100)
ctx.draw(true)

# sample code

the second time draw() reserve for false。 So the result of the previous drawing is not preserved and the fillStyle 'red'。

const ctx = wx.createCanvasContext('myCanvas')

ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 100)
ctx.draw()
ctx.fillRect(50, 50, 150, 100)
ctx.draw()