Get_Pixel

variable <- Get_Pixel(X, Y)

 

Get_Pixel is a function that returns the color of the pixel at the given X,Y location. The (x,y) coordinates passed to Get_Pixel must be valid coordinates for the current graphics window. If they represent a point off the screen, Get_Pixel will immediately generate a run-time error causing your program to stop running.

 

Get_Pixel is normally used in an assignment, as shown above. However, because it returns a value, it can also be used in comparisons where ever a numeric value would work. For example, we may want our program to exit a loop when a green pixel is found at the current location, so the loop's diamond symbol might contain the following comparison:

 

Get_Pixel(x1,y1) = Green

 

Note:  A graphics window must be open when Get_Pixel is called or a run-time error will occur.

 

Specific Assignment Example:

 

Color <- Get_Pixel(200,200);