admin管理员组文章数量:1406177
If I have 2 canvases:
The first canvas (canvas1) is the basic one that contains text and will be saved as an image (canvas1 + canvas2).
The second one (canvas2) contains an image that can be moved within canvas2 through keydown
. The code works fine with canvas2 as I cleared first canvas2 then context2.drawImage(img,x,y)
.
But If i write( canvas1.drawImage(canvas2, 0, 0)
then the movements of the image is shown in canvas 1. And if i said clear canvas 1 then canvas1.drawImage(canvas2, 0, 0)
the text will disappear.
So my question is: how can I draw canvas 2 on canvas 1 when the user finishes moving the image not during the image's movement?
If I have 2 canvases:
The first canvas (canvas1) is the basic one that contains text and will be saved as an image (canvas1 + canvas2).
The second one (canvas2) contains an image that can be moved within canvas2 through keydown
. The code works fine with canvas2 as I cleared first canvas2 then context2.drawImage(img,x,y)
.
But If i write( canvas1.drawImage(canvas2, 0, 0)
then the movements of the image is shown in canvas 1. And if i said clear canvas 1 then canvas1.drawImage(canvas2, 0, 0)
the text will disappear.
So my question is: how can I draw canvas 2 on canvas 1 when the user finishes moving the image not during the image's movement?
Share Improve this question edited Jul 13, 2011 at 20:58 pimvdb 155k80 gold badges311 silver badges356 bronze badges asked Jul 13, 2011 at 20:45 AmalAmal 813 silver badges7 bronze badges2 Answers
Reset to default 3I'm not entirely clear why you would want to do this, but if you want Canvas 1 to always display canvas 1+2, then you can always save the contents of Canvas 1:
- Draw Canvas 1 to an in-memory canvas (call it canvas3)
- Draw Canvas 2 to Canvas 1
- Draw Canvas 3 (which was Canvas 1 saved) back to Canvas 1
http://jsfiddle/Jvgxb/14/
Try to make two DIVs over each other. each of those DIVs should contain one of your canvases :)
本文标签: javascriptmerging two canvasesStack Overflow
版权声明:本文标题:javascript - merging two canvases - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744970131a2635184.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论