Canvas globalAlpha Property

Watch a demo of different values of the globalAlpha property.

Or click a specific value to see the result:

globalAlpha = 0.1;
globalAlpha = 0.2;
globalAlpha = 0.3;
globalAlpha = 0.4;
globalAlpha = 0.5;
globalAlpha = 0.6;
globalAlpha = 0.7;
globalAlpha = 0.8;
globalAlpha = 0.9;
globalAlpha = 1.0;
globalAlpha = 0.0;
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
your browser does not support the canvas tag
let c = document.getElementById('myCanvas');
let ctx = c.getContext('2d');
ctx.fillStyle='red';
ctx.fillRect(20,20,75,50);
ctx.globalAlpha=0.2;
ctx.fillStyle='blue';  
ctx.fillRect(50,50,75,50);

Play more with the code in our Tryit yourself editor: Try it Yourself ❯