admin管理员组文章数量:1419891
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 e 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 inpatible 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,
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 e 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 inpatible 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,
Share Improve this question edited Apr 21, 2011 at 14:13 Mechanicum asked Apr 21, 2011 at 7:40 MechanicumMechanicum 411 silver badge3 bronze badges 1- Do you have an example set up for what you have? I think I may know what you need to do, but just not quite sure if I am on the right page with you. – jaredwilli Commented Jan 21, 2012 at 13:10
1 Answer
Reset to default 5You must pass the canvas as first parameter to drawImage. Not the context.
ctx.drawImage(ghostcanvas, corx, cory);
本文标签: javascriptCanvas context drawImage() problemStack Overflow
版权声明:本文标题:javascript - Canvas context drawImage() problem - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745313201a2653030.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论