设置全局画笔透明度。
参数 | 类型 | 范围 | 说明 |
---|---|---|---|
alpha | number | 0~1 | 透明度,0 表示完全透明,1 表示完全不透明 |
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()