画布html5中的透明度context.fill样式

mgh*_*mgh 5 javascript html5 canvas

我写这个javascript代码:

context.shadowOffsetX = 5;
context.shadowOffsetY = 5;
context.shadowBlur = 4;
context.shadowColor = 'rgba(255, 0, 0, 0.5)';
context.fillStyle = '#f00';
context.fillRect(x, y, w, h);
Run Code Online (Sandbox Code Playgroud)

我在照片上添加了这个脚本,我希望看到图像的颜色,但无法为此脚本添加透明度.

Mil*_*ous 14

尝试制作fillStyle RGBA.

context.fillStyle = 'rgba(255, 0, 0, 0.5)';
context.fillRect(x, y, w, h);
Run Code Online (Sandbox Code Playgroud)