Type Function Library display.* Return value none Revision Release 2024.3703 Keywords color, sampling, screen
Get the color of a pixel on screen.
display.colorSample( x, y, listener )
Number. The x coordinate of the pixel on screen, in content coordinates.
Number. The y coordinate of the pixel on screen, in content coordinates.
Listener. The event listener to receive the result.
display.colorSample()
has similar performance limitations as display.capture(). This function should not be called in a tight loop, during a Runtime "enterFrame"
listener, or during a touch listener’s "moved"
phase.
local function onColorSample( event ) print( "Sampling pixel at position (" .. event.x .. "," .. event.y .. ")" ) print( "R = " .. event.r ) print( "G = " .. event.g ) print( "B = " .. event.b ) print( "A = " .. event.a ) end display.colorSample( 17, 9, onColorSample )