WeChat Mini Program API drawing·draw (drawing)


draw


Definition

Draw the description (path, transformation, style) previously in the drawing context into the canvas.

Tip: The drawing context needs to be created by wx.createCanvasContext(canvasId).

Parameters

QQ截图20170208150043.png

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

201612270954394950.png


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)