May 19, 2021 WeChat Mini Program Development Document
Drawing interfaces and methods
Set global brush transparency.
Parameters | Type | Range | Description |
---|---|---|---|
alpha | Number | 0~1 | Transparency, 0 for full transparency, and 1 for total opacity |
const ctx = wx.createCanvasContext('myCanvas')
ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 100)
ctx.setGlobalAlpha(0.2)
ctx.setFillStyle('blue')
ctx.fillRect(50, 50, 150, 100)
ctx.setFillStyle('yellow')
ctx.fillRect(100, 100, 150, 100)
ctx.draw()