Getting pixel color in place with pygame

I draw a bunch of rectangles on a siaply screen, and I wonder how I will read reading rgb color at a specific pixel location? For example, I want to get the color of a pixel in the place 0,0 on the display screen and return the value [0,0,0] (or the like).

+6
source share
1 answer

http://www.pygame.org/docs/ref/surface.html#Surface.get_at

Surface.get_at((x, y)): return Color

Return a copy of the RGBA color value in this pixel. If the surface does not have an alpha pixel, then the alpha value will always be 255 (opaque). If the pixel position is outside the Surface area, an IndexError exception will be raised.

+7
source

Source: https://habr.com/ru/post/913566/


All Articles