I know this is old, but I don't think the previously accepted answer is correct. I think this happens as a result of truncating the pixel values ββfrom a floating point number to bytes. In Windows 7 running Chrome version 39.0.2171.95m, after starting the violin for a while, the image is still visible, but only slightly, and it seems to no longer change. If I take a screenshot, I see the following pixel values ββin the image:
(246, 246, 246)
When you draw a rectangle over it with rgba:
(255, 255, 255, 0.1)
and apply alpha blending using the default layout mode with the overlay of the source code, before converting to the byte you get:
(255 * 0.1 + 246 * 0.9) = 246.9
So you can see that, assuming the browser just truncates the floating point value to a byte, it writes the value 246, and each time you repeat the drawing operation, you will always get the same value.
There is a lot of discussion on this subject on this blog here .
As a workaround, you can constantly clear the canvas and redraw the image with decreasing globalAlpha value. For instance:
// Clear the canvas ctx.globalAlpha = 1.0; ctx.fillStyle = "rgb(255, 255, 255)"; ctx.fillRect(0,0,canvas.width(),canvas.height()); // Decrement the alpha and draw the image alpha -= 0.1; if (alpha < 0) alpha = 0; ctx.globalAlpha = alpha; console.log(alpha); ctx.drawImage(image, 0, 0, 256, 256); setTimeout(draw, 100);
The violin is here .