Table of Contents

Pixel (Function)

Format

pixel (x_position, y_position )

returns rgb_expr

Description

Returns the RGB value of the pixel at the x_position and y_position coordinate. If the pixels has not been set since the last Clg command or was drawn with the color CLEAR a -1 will be returned.

Sample Program

The following sample program shows how to use the binary and operation and integer division to extract the red, blue, and green values from the number returned by pixel.

color red
rect 0,0,100,100

color rgb(100,50,150)
rect 100,100,100,100

color white
rect 200,200,100,100

while true
	c = pixel(mousex, mousey)
	r = (c & 0xff0000) \ 0x10000
	g = (c & 0xff00) \ 0x100
	b = (c & 0xff)
	print r,g,b
	pause .5
end while

See Also

2016/01/01 22:42

History

0.9.5mNew To Version
2.0.0.4Added example