その上に半透明の長方形を描くことができます。例えば:
ctx.fillStyle = 'rgba(255, 0, 0, 0.5)'; // 1/2 opacity red
ctx.fillRect(0, 0, 30, 30); // Draw this over top of your image
これがデモです。
アイソメ画像の場合は、適切なパスを作成するだけです。その例を次に示します。
globalCompositeOperationを次のように設定することで、オーバーレイを画像にクリップできますsource-atop。
ctx.globalCompositeOperation = 'source-atop';
ctx.fillStyle = 'rgba(255, 0, 0, 0.5)'; // 1/2 opacity red
ctx.fillRect(0, 0, 30, 30); // Draw this over top of your image
ctx.globalCompositeOperation = 'source-over';
これがデモです。ただし、描画しようとしている領域にもコンテンツがある場合は、シャドウ キャンバスを使用する必要がある場合もあります。