May 19, 2021 WeChat Mini Program Development Document
Drawing interfaces and methods
Start creating a path that needs to be called fill orstroke before you can use the path for padding or stroke.
Tip:
At the beginning, it's the equivalent of
beginPath()
Tip
: Multiple
setFillStyle()
setStrokeStyle()
setLineWidth()
within the same path, set To be accurate for the last time.
const ctx = wx.createCanvasContext('myCanvas')
// begin path
ctx.rect(10, 10, 100, 30)
ctx.setFillStyle('yellow')
ctx.fill()
// begin another path
ctx.beginPath()
ctx.rect(10, 40, 100, 30)
// only fill this rect, not in current path
ctx.setFillStyle('blue')
ctx.fillRect(10, 70, 100, 30)
ctx.rect(10, 100, 100, 30)
// it will fill current path
ctx.setFillStyle('red')
ctx.fill()
ctx.draw()