CanvasContext.setGlobalAlpha

Set the alpha of global brush.

Parameters

It is Object type.

PropertyTypeRangeDescription
alphaNumber 0-1The alpha value, 0 represents transparent and 1 represents non-transparent.

Sample Code

copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')

ctx.setFillStyle('yellow')
ctx.fillRect(10, 10, 150, 100)
ctx.setGlobalAlpha(0.2)
ctx.setFillStyle('blue')
ctx.fillRect(50, 50, 150, 100)
ctx.setFillStyle('red')
ctx.fillRect(100, 100, 150, 100)

ctx.draw()