A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/apis/canvas/CanvasRenderingContext2D/globalAlpha below:

globalAlpha ยท WebPlatform Docs

globalAlpha Summary

An alpha value that is applied to shapes and images before they are composited onto the canvas.

Property of apis/canvas/CanvasRenderingContext2Dapis/canvas/CanvasRenderingContext2D

Syntax
var result = CanvasRenderingContext2D.globalAlpha;
CanvasRenderingContext2D.globalAlpha = value;
Return Value

Returns an object of type NumberNumber

Default is 1.0.

Examples

The following example draws a semi-transparent white circle on a green background

function draw() {
  var ctx = document.getElementById('canvas').getContext('2d');
  
  ctx.fillStyle = '#FD0';
  ctx.fillRect(0,0,150,150)

  
  ctx.globalAlpha = 0.2;

  
  ctx.beginPath();
  ctx.arc(75,75,50,0,Math.PI*2,true);
  ctx.fill();
}
Notes

If you set the globalAlpha property to a value outside the range (including infinity or not a number (NaN)), the previous value is preserved.

Related specifications
W3C HTML Canvas 2D Specification
W3C Candidate Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4