Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat Program API Drawing draw (drawing)


May 19, 2021 WeChat Mini Program Development Document


Table of contents


WeChat Program API Drawing draw (drawing) Drawing interfaces and methods

canvasContext.draw


Defined

Draw the previous descriptions (paths, deformations, styles) in the drawing context into canvas.

Tip: The drawing context wx.createCanvasContext(canvasId)

Parameters

Parameters Type Description The lowest version
reserve Boolean Not required. Whether this draw is followed by the last draw, i.e. the reserve parameter is false, the native layer should empty the canvas before drawing this call drew, and if the reserver parameter is true, the content on the current canvas is preserved, and the content drawn by this call drew on the drawing is overwritten on it, the default false
callback Function The callback is complete when the drawing is complete 1.7.0


Example

const ctx = wx.createCanvasContext('myCanvas')

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

WeChat Program API Drawing draw (drawing)


Example

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)

WeChat Program API Drawing draw (drawing)

WeChat Program API Drawing draw (drawing) Drawing interfaces and methods