Page 1 of 1
finding color value of pixel on screen
Posted: Thu Jan 09, 2014 5:18 pm
by fmra
Is it possible to check the color values of a pixel at x,y on the screen? I have a table with a list of pixels I'm moving around, but I'd like to be able to check unmapped areas of the screen for pixels without nesting iterators.
Re: finding color value of pixel on screen
Posted: Thu Jan 09, 2014 5:48 pm
by DaedalusYoung
You can use
love.graphics.newScreenshot to get the screen as ImageData, and then use
ImageData:getPixel to find the pixel's colour value.
Note that this will create lag when generating the screenshot though, so it's probably best to find another solution.
Re: finding color value of pixel on screen
Posted: Thu Jan 09, 2014 6:57 pm
by veethree
Draw the stuff to a
canvas, Then you can use
canvas:getPixel(x, y)
Re: finding color value of pixel on screen
Posted: Thu Jan 09, 2014 7:00 pm
by slime
Both of those options are incredibly slow for real-time use. It's best to think of the color of pixels on your screen (or in Canvases) as inaccessible through CPU-side code except in certain circumstances (occasional screenshots), and plan accordingly.
Re: finding color value of pixel on screen
Posted: Thu Jan 09, 2014 7:11 pm
by fmra
yeah, I think I came up with a work around. I created a new table that tallies the x position for each pixel and alters the equations for pixel movement. Insincere, but visually identical to what I was trying to do. Thank you everyone.