Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting pixel color at location with pygame

Tags:

python

pygame

I'm drawing a bunch of rectangles to the siaply screen, and I'm wondering how I would go about reading the rgb color at a certain pixel location? For example, I want to get the color of the pixel at location 0,0 on the display screen, and it return the value [0,0,0] (or similar).

like image 364
Samsquanch Avatar asked Apr 18 '12 18:04

Samsquanch


1 Answers

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 at the given pixel. If the Surface has no per pixel alpha, then the alpha value will always be 255 (opaque). If the pixel position is outside the area of the Surface an IndexError exception will be raised.

like image 118
FogleBird Avatar answered Sep 28 '22 06:09

FogleBird