How to copy a kineticjs stage to another canvas

假装没事ソ 提交于 2019-12-01 22:18:45
Eric Rowell

access a layer canvas element like this:

var canvasElement = layer.getCanvas().getElement();

and the context like this:

var context = layer.getCanvas().getContext();

Here's the docs of interest:

http://kineticjs.com/docs/Kinetic.Layer.html#getCanvas

http://kineticjs.com/docs/Kinetic.Canvas.html

With the last and newer version of kineticjs the method from the as correct marked answer doesn't work anymore. Nowadays I just used the following approach to get the kineticjs main canvas - with the help of jquery:

var canvas = $('#canvasDiv').find('canvas');
console.log("Canvas: %O", layerCanvas);

Just replace

 #canvasDiv

with the ID of your container.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!