Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
これを使用して長方形の HTML5 要素を描画するとします。
context.clearRect(25, 72, 32, 32);
どうすれば 50% 透明にできますか?
グローバルアルファを使用します。また、fillRect で描画する必要があります。clearRect はピクセルを消去するだけです。部分的に消去することはできないため、fillRect またはその他の描画プリミティブを使用する必要があります。
w3schools.comから:
ctx.globalAlpha = 0.2; ctx.fillRect(50,50,75,50); ctx.globalAlpha = 1.0;