Question

I can't figure how to make drawImage work... It just does nothing (except that it throws an exception with an undefined description) :

layerCtx.globalAlpha = 0,2; // same thing with this line commented
layerCtx.drawImage(cvs, 0 , 0);

I have 2 canvas, one is a layer and the other is for drawing using the mouse. I want to save what the user has drawn on the first canvas to the layer and apply opacity... I won't give you all the code but you have to know that the following code works :

layerCtx.putImageData(ctx.getImageData(0, 0, 800, 500), 0, 0);

but I can't use opacity with the previous, so as it is advised in other stackoverflow.com related questions, I'd like to use drawImage with a canvas element.

ctx is the context for my canvas cvs,
layerCtx is the context fort my canvas layer

Was it helpful?

Solution

You're gonna hate this: You wrote 0,2 instead of 0.2. That's why it isn't working.

I know a comma is used as a decimal in a lot of European countries, but 0.2 is what its gotta be for this.

Working example to check your code by:

http://jsfiddle.net/zC4Wh/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top