阅读(4708) (9)

微信小程序API 绘图中使用setGlobalAlpha设置全局画笔透明度

2016-12-26 18:06:39 更新

绘图接口和方法绘图接口和方法

canvasContext.setGlobalAlpha


定义

设置全局画笔透明度。

参数

参数类型范围说明
alphaNumber0~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()


微信小程序 canvas接口和方法绘图接口和方法