5

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 .

P. Frank
  • 5,593
  • 6
  • 20
  • 48
mgh
  • 881
  • 3
  • 9
  • 35

1 Answers1

17

Try making the fillStyle RGBA, too.

context.fillStyle = 'rgba(255, 0, 0, 0.5)';
context.fillRect(x, y, w, h);
MildlySerious
  • 8,112
  • 2
  • 27
  • 29