newbiedev Posted August 29, 2022 Share Posted August 29, 2022 Hello, as the title implies, I'm trying to create a hitover area using a PNG binary mask instead of a polygon mask. I couldn't really find something for this in the documentation. Is that possible? Currently, I start with a PNG binary mask, convert it to a polygon (list of [x,y] coordinates), and then mask my sprites for a hitover area. This works really well when the initial binary mask is well defined and closed. However, if the binary mask has disconnected components, the hitover area yields unwanted actions. Probably due to there being multiple polygons during the mask -> polygon process. Thanks so much in advance! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 29, 2022 Share Posted August 29, 2022 convert mask to polygon - sorry, pixi doesnt have that. though , pixel perfect interaction is here: https://github.com/pixijs/pixijs/wiki/v5-Hacks#pixel-perfect-interaction Quote Link to comment Share on other sites More sharing options...
Avihaa Posted August 31, 2022 Share Posted August 31, 2022 reshape(3,3,3) #3 channel image mask = np. zeros(shape=(3,3)) mask[1,1] = 1 # binary mask mask_3d = np. stack((mask,mask,mask),axis=0) #3 channel mask ## Answer 1 # Simply multiply the image array with the mask masked_arr = arr*mask_3d ## Answer 2 # Use the where function in numpy masked_arr = np. Quote Link to comment Share on other sites More sharing options...
newbiedev Posted September 1, 2022 Author Share Posted September 1, 2022 @ivan.popelyshev Thanks for the comment! I meant to say that I convert my PNG binary mask to polygon outside of PIXI. I use Python to pre-compute the polygons. I'll try the link you sent above. Quote Link to comment Share on other sites More sharing options...
Avihaa Posted February 25, 2023 Share Posted February 25, 2023 reshape(3,3,3) #3 channel image mask = np. zeros(shape=(3,3)) mask[1,1] = 1 # binary mask mask_3d = np. stack((mask,mask,mask),axis=0) #3 channel mask ## Answer 1 # Simply multiply the image array with the mask masked_arr = arr*mask_3d ## Answer 2 # Use the where function in numpy masked_arr = np. anonigviewer bingenerator 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.