# CanvasContext.fill()

with Promise style call: Not supported

Mini Program plugin: Support

Populates the contents of the current path. The default fill color is black.

# sample code

If the current path is not closed, fill() Method concatenates the start and end points and populates them.

const ctx = wx.createCanvasContext('myCanvas')
ctx.moveTo(10, 10)
ctx.lineTo(100, 10)
ctx.lineTo(100, 100)
ctx.fill()
ctx.draw()

fill() The path of the padding is derived from the beginPath() Starts the calculation, but does not set the fillRect() Include it.

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