HTMLキャンバスglobalAlphaプロパティ
例
まず、赤い長方形を描画し、次に透明度(globalAlpha)を0.5に設定してから、青と緑の長方形を描画します。
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 75, 50);
// Turn transparency on
ctx.globalAlpha = 0.2;
ctx.fillStyle = "blue";
ctx.fillRect(50, 50, 75, 50);
ctx.fillStyle = "green";
ctx.fillRect(80, 80, 75, 50);
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
globalAlpha | |||||
---|---|---|---|---|---|
font | Yes | 9.0 | Yes | Yes | Yes |
定義と使用法
globalAlphaプロパティは、図面の現在のアルファ値または透明度の値を設定または返します。
globalAlphaプロパティ値は、0.0(完全に透過的)から1.0(透明性なし)までの数値である必要があります。
デフォルト値: | 1.0 |
---|---|
JavaScript構文: | context .globalAlpha = number ; |
プロパティ値
Value | Description | Play it |
---|---|---|
number | The transparency value. Must be a number between 0.0 (fully transparent) and 1.0 (no transparancy) |
❮HTMLキャンバスリファレンス