lilsheep Posted August 4, 2015 Share Posted August 4, 2015 Is this possible? I have been messing around with Pixi for a few minutes as well as googling and haven't been able to figure that out. (For the sake of collision detection btdubs) Quote Link to comment Share on other sites More sharing options...
xerver Posted August 4, 2015 Share Posted August 4, 2015 I recommend against using pixel-perfect collision detection, it is rarely needed. That being said you can extract the pixels of an image using the canvas api:// assume "img" is your image elementvar canvas = document.getElementById('mycanvas');var ctx = canvas.getContext('2d');canvas.width = img.width;canvas.height = img.height;ctx.drawImage(img, 0, 0, img.width, img.height);var pixelData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;That will return a Float32Array of the pixels in the format [R,G,B,A, R,G,B,A, ...] 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.