agamemnus Posted September 16, 2014 Share Posted September 16, 2014 Topic. Quote Link to comment Share on other sites More sharing options...
Sebi Posted September 16, 2014 Share Posted September 16, 2014 The same way it is done here: http://www.html5gamedevs.com/topic/6748-pixi-texture-to-image-object/https://github.com/GoodBoyDigital/pixi.js/blob/master/bin/pixi.dev.js line 2025 PIXI.Sprite.prototype._renderCanvas Quote Link to comment Share on other sites More sharing options...
agamemnus Posted September 16, 2014 Author Share Posted September 16, 2014 Ah, I see. Is there any more direct way to copy a texture? Must I convert to canvas and back to a texture? Quote Link to comment Share on other sites More sharing options...
agamemnus Posted September 16, 2014 Author Share Posted September 16, 2014 And a related question -- perhaps you can answer -- Is there any way to render a canvas element to a RenderTexture? .... or set the renderTexture's texture to match that of a canvas element's texture? Quote Link to comment Share on other sites More sharing options...
Mat Groves Posted September 17, 2014 Share Posted September 17, 2014 Hey there! Sounds like you need a renderTexture! You could then make a sprite with your canvas and then render that to the renderTexture? What is your goal? ta! Quote Link to comment Share on other sites More sharing options...
agamemnus Posted September 17, 2014 Author Share Posted September 17, 2014 I have a jigsaw game where I need to modify piece images when they are joined or when they are added to the central area. At the moment I am destroying the texture and re-adding the canvas every time the canvas changes. I guess I am a bit lost on how exactly the texture stuff works... for example, I see a <canvas> element in the object structure after I create a texture, but getting its context and then modifying it does nothing unless I "destroy" the texture object and re-make it.I don't know what the most efficient way of doing this is. I could possibly use the PIXI primitives to do everything (the pieces have a border and soft bevel which I make with <canvas> functions) but I haven't gotten to that yet... Quote Link to comment Share on other sites More sharing options...
hubert Posted September 17, 2014 Share Posted September 17, 2014 are all your pieces like squares or do they have "inter-lapping" elements that enter each other?? http://www.sevenative.com Quote Link to comment Share on other sites More sharing options...
agamemnus Posted September 19, 2014 Author Share Posted September 19, 2014 No, they are overlapping: http://www.html5gamedevs.com/topic/9003-my-jigsaw-game-safari-jigsaw/ Quote Link to comment Share on other sites More sharing options...
hubert Posted September 19, 2014 Share Posted September 19, 2014 Hi! In this thread you can read more about the render texture method and how to use it. http://www.html5gamedevs.com/topic/6507-display-object-container-to-an-imagesprite/#entry38726 Additional info about renderTexture cropping with newer versions of pixi.js (1.6.0 used) http://www.html5gamedevs.com/topic/8613-upgrading-to-pixi-160/#entry51302 But then again if they have interlapping elements why would you like to render parts of them into the canvas gain and not just leave them together connected with sort of snap to the edge method and not allow them to be disconnected? http://www.sevenative.com Quote Link to comment Share on other sites More sharing options...
agamemnus Posted September 21, 2014 Author Share Posted September 21, 2014 There is an option to leave them connected (or not). I also have other cases where I need to modify the image itself. 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.