Pget

From Pico-8 Wiki
Jump to navigation Jump to search
pget( x, y )
Gets the color value of a pixel at the given coordinates.
x
The x coordinate.

y
The y coordinate.

The pget() function reads the color value of a pixel from the graphics buffer.

It will read from the buffer even if the buffer has not yet been copied to the display.

It will return 0 (black) if given coordinates outside the range (0-127,0-127).

Examples

pset(10, 10, 7)                 -- sets (10, 10) to white
print(pget(10, 10), 0, 112, 7)  -- prints 7

pset(10, 10, 8)                 -- sets (10, 10) to red
print(pget(10, 10), 0, 120, 7)  -- prints 8

flip()  -- displays the red (8) pixel and the messages

See also