Reputation: 41
I basically want to put a shape that the user "cuts" from the main canvas to a random place in the main canvas. I hold the cut out shape's context and want to use;
ctx.drawImage(gctx,corx,cory);
to put gctx, which holds the context of the cut shape in to ctx, which is the main canvas context. Both are global and already set when they come upon the above code line. Also gctx is set as below;
ghostcanvas = document.createElement('canvas');
ghostcanvas.height = canvas.height;
ghostcanvas.width = canvas.width;
gctx = ghostcanvas.getContext('2d');
From firebug i can see that there is a context in gctx, ctx is also there. So what am i doing wrong?
Forgot to add the error message i got;
The type of an object is incompatible with the expected type of the parameter associated to the object" code: "17 [Break On This Error] ctx.drawImage(gctx,corx,cory);
Thanks in advance also sorry in advance if it's a major newbie question,
Upvotes: 4
Views: 5449
Reputation: 22020
You must pass the canvas as first parameter to drawImage. Not the context.
ctx.drawImage(ghostcanvas, corx, cory);
Upvotes: 5