CanvasContext.draw

Draw the description in the context such as path, style to the canvas.

Parameters

It is Object type.

PropertyType

Required

Default ValueDescription
reserveBooleanNofalse If this drawing is to continue with the previous drawing, that is, the reserve parameter is false, then the native layer should first empty the canvas before the drawCanvas drawing is called. If the reserver parameter is true, the contents of the current canvas are retained and the contents drawn by the call to drawCanvas are overridden.
callbackFunctionNo-The callback function when draw finishes.

Sample Code

copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')

ctx.setFillStyle('blue')
ctx.fillRect(20, 20, 180, 80)
ctx.draw()
ctx.fillRect(60, 60, 250, 120)
// keep the last draw result
ctx.draw(true)
copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')

ctx.setFillStyle('blue')
ctx.fillRect(20, 20, 180, 80)
ctx.draw()
ctx.fillRect(60, 60, 250, 120)
// do not keep the last draw result
ctx.draw(false)