Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat's small program API drawing uses setGlobalAlpha to set global brush transparency


May 19, 2021 WeChat Mini Program Development Document


Table of contents


WeChat's small program API drawing uses setGlobalAlpha to set global brush transparency Drawing interfaces and methods

canvasContext.setGlobalAlpha


Defined

Set global brush transparency.

Parameters

Parameters Type Range Description
alpha Number 0~1 Transparency, 0 for full transparency, and 1 for total opacity

Example

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

WeChat's small program API drawing uses setGlobalAlpha to set global brush transparency

WeChat's small program API drawing uses setGlobalAlpha to set global brush transparency Drawing interfaces and methods