dst Posted August 18, 2014 Share Posted August 18, 2014 I know that I can draw a Sprite to a RenderTexture but is there any way to draw a sprite to a canvas element? Or somehow get a canvas or image element out of a RenderTexture? I would like to draw a complex sprite with multiple children to a canvas/image so that I can then perform globalCompositeOperations on it i.e. draw a source image into it using "source-atop". For example:var sourceImage = new Image();sourceImage.src = "mySourceImage.png";var mySpriteCanvas = mySprite.toCanvas();mySpriteCanvas.context.globalCompositeOperation = 'source-atop';mySpriteCanvas.context.drawImage(sourceImage, 0, 0);var baseTexture = new PIXI.BaseTexture(mySpriteCanvas);var texture = new PIXI.Texture(baseTexture);var myCompositeSprite = new PIXI.Sprite(texture);stage.addChild(myCompositeSprite);Is it possible to do something like this? Quote Link to comment Share on other sites More sharing options...
powerfear Posted August 19, 2014 Share Posted August 19, 2014 RenderTexture has a method called getCanvas() on the latest pixi version (dev branch) Quote Link to comment Share on other sites More sharing options...
dst Posted August 19, 2014 Author Share Posted August 19, 2014 Awesome, thanks! Will try this out Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.