Core Function PixelSearch
(→Description) |
(→Return Value) |
||
Line 44: | Line 44: | ||
Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y) | Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y) | ||
− | Failure: Returns 0. | + | |
+ | Failure: Returns 0. | ||
=== Remarks === | === Remarks === |
Revision as of 06:09, 28 November 2011
PixelSearch ( <left>, <top>, <right>, <bottom>, <colour>, <shade>, <step> )
Contents |
Description
Searches a rectangle of pixels for the pixel color provided.
Parameters
left
left coordinate of rectangle.
top
top coordinate of rectangle.
right
right coordinate of rectangle.
bottom
bottom coordinate of rectangle.
colour
Colour value of pixel to find (in decimal or hex).
shade
Optional; A number between 0 and 255 to indicate the allowed number of shades of variation of the red, green, and blue components of the colour.
Default is 0 (exact match).
step
Optional; Instead of searching each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel.
Default is 1.
Return Value
Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
Failure: Returns 0.
Remarks
The search is performed top-to-bottom, left-to-right, and the first match is returned.
RGB is used to define colours by default but this can be changed using the ColourMode option.
Performing a search of a region can be time consuming, so use the smallest region you are able to reduce CPU load.
See "PixelCoordMode" in Opt
Example
$coord = PixelSearch( 35, 99, 600, 600, 0x0000ff ); If ( $coord ) { MsgBox("X and Y are: $coord[0] , $coord[1]"); } Else { MsgBox("not found"); } // OR List ($x, $y) = PixelSearch( 35, 99, 600, 600, 0x0000ff ); If ( $x && $y ) // It is true this will fail a match at coordinate 0,0 but its unlikely that it would matter { MsgBox("X and Y are: $x, $y"); } Else { MsgBox("not found"); }