finding color value of pixel on screen
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
finding color value of pixel on screen
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.
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: finding color value of pixel on screen
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.
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
Draw the stuff to a canvas, Then you can use canvas:getPixel(x, y)
- slime
- Solid Snayke
- Posts: 3163
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: finding color value of pixel on screen
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
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.
Who is online
Users browsing this forum: Bing [Bot] and 8 guests