javascript - KineticJS: How to convert a Stage with n Layers to a Canvas? -
javascript - KineticJS: How to convert a Stage with n Layers to a Canvas? -
i have seen question how re-create kineticjs stage canvas shows can convert layer canvas as:
var canvaselement = layer.getcanvas().getelement(); and context this:
var context = layer.getcanvas().getcontext(); but if have stage n, n > 1 layers how convert layers 1 canvas?
you "convert layers on canvas"...implying html5 canvas rather kinetic.
example code , demo: http://jsfiddle.net/m1erickson/cbxuj/
var canvas=document.createelement("canvas"); var ctx=canvas.getcontext("2d"); document.body.appendchild(canvas); stage.toimage({ x:0, y:0, width:stage.width(), height:stage.height(), callback:function(img){ canvas.width=img.width; canvas.height=img.height; ctx.drawimage(img,0,0); } }); javascript html html5 canvas kineticjs
Comments
Post a Comment