tbird Posted June 19, 2020 Share Posted June 19, 2020 I know how to get the raw pixel data of the original texture of an image sprite, but is there a way to get the pixel data of the sprite just before it is composited with all of the other elements, but after it has been altered by scaling, filters, etc? renderer.extract.pixels(mysprite) seems to just return the original texture no matter what transformations have been performed on the sprite. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 19, 2020 Share Posted June 19, 2020 put it to container, extract pixels from container. In any case, I always recommend to look how that `pixels` work - its actually several difficult operations, and any of them can misfire. gettngs bounds of object + render to texture + readPixels Quote Link to comment Share on other sites More sharing options...
tbird Posted June 20, 2020 Author Share Posted June 20, 2020 Are you saying pixels is unreliable? If so, is there an alternative? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 20, 2020 Share Posted June 20, 2020 Unreliable = "we (community) found so many bugs in it, there can be more" The only thing you can do is to be aware of how its done and do parts manually if something goes wrong. Quote Link to comment Share on other sites More sharing options...
tbird Posted June 24, 2020 Author Share Posted June 24, 2020 I'm writing this as a favor for a public school teacher. I have an image of a geographical map with a bunch of "hot" areas that I want to be able to individually detect clicks on. My plan is to use different bitmap masks to represent each different area so they can scale to fit the browser window bounds along with the image. Then I was going to use pixels() to detect the alpha values of the mask pixel the mouse cursor is over. Is there a smarter way to do arbitrary click-area detection that doesn't use pixels()? Thank you for your help! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 24, 2020 Share Posted June 24, 2020 > Then I was going to use pixels() to detect the alpha values of the mask pixel the mouse cursor is over. https://github.com/pixijs/pixi.js/wiki/v5-Hacks#pixel-perfect-interaction Quote Link to comment Share on other sites More sharing options...
tbird Posted June 25, 2020 Author Share Posted June 25, 2020 (edited) You are a god. Will that work if even if the stage scales after a change in the browser window dimensions? Edited June 25, 2020 by tbird ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 27, 2020 Share Posted June 27, 2020 (edited) yes, i should, all resizes are handled with coordinates transformation (toLocal/toGlobal stuff) in case something fails, check if interactionManager actually has correct coords of mouse, "renderer.plugins.interaction.somethingsomething" , you can override positioning function if you need : https://github.com/pixijs/pixi.js/wiki/v4-Gotchas#css-transforms-on-canvas Edited June 27, 2020 by ivan.popelyshev 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.