Transparency context.fill style in canvas html5 [closed]

流过昼夜 提交于 2021-01-27 05:21:06

问题


I write this javascript code :

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);

I add this script on a photo , I want see the color of image , but can not add transparency to this script .


回答1:


Try making the fillStyle RGBA, too.

context.fillStyle = 'rgba(255, 0, 0, 0.5)';
context.fillRect(x, y, w, h);


来源:https://stackoverflow.com/questions/19132064/transparency-context-fill-style-in-canvas-html5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!