May 19, 2021 WeChat Mini Program Development Document
Drawing interfaces and methods
Clear the contents of the canvas in the rectangular area.
Tip : ClearRect does not draw a white rectangle in the address area, but emptys it, adding a background color to the canvas for visual experience.
<canvas canvas-id="myCanvas" style="border: 1px solid; background: #123456;"/>
Parameters | Type | Description |
---|---|---|
Ⅹ | Number | The x coordinates in the upper-left corner of the rectangular area |
Y | Number | The y coordinates in the upper-left corner of the rectangular area |
width | Number | The width of the rectangular area |
height | Number | The height of the rectangular area |
const ctx = wx.createCanvasContext('myCanvas')
ctx.setFillStyle('red')
ctx.fillRect(0, 0, 150, 200)
ctx.setFillStyle('blue')
ctx.fillRect(150, 0, 150, 200)
ctx.clearRect(10, 10, 150, 75)
ctx.draw()