Find color in image (:find_color)
Declaration
x, y = img:find_color({
[find_all = find_all,]
[max_results = max_results,]
[max_miss = max_miss,]
[find_order = find_order,]
[csim_algorithm = color_similarity_algorithm,]
{start_x, start_y, start_color[, start_similarity]},
{dx*, dy*, color*[, similarity*]},
{dx*, dy*, color*[, similarity*]},
...
} [, global_similarity, left, top, right, bottom ])
Parameters
-
find_all
Boolean, optional. If true, returns all matches within range as{{x1,y1},{x2,y2},...}
. Default false -
max_results
Integer, optional. When find_all is true, the maximum number of results to return (<=1000
). Default 100 -
max_miss
Integer, optional. Maximum allowed unmatched points. Default 0 (must match all) -
find_order
Integer, optional. Search order 1~8. Default 1Find order values
1 Up-Down-Left-Right
2 Left-Right-Up-Down
3 Right-Left-Up-Down
4 Up-Down-Right-Left
5 Down-Up-Right-Left
6 Right-Left-Down-Up
7 Left-Right-Down-Up
8 Down-Up-Left-RightScreen API screen.find_color does not have this field
Order demo -
color_similarity_algorithm 20250302
Integer, optional. Default 0Color similarity algorithms
0 XXT default algorithm, steep gradient
1 Manhattan distance, smooth gradient
2 Euclidean distance, smooth gradient -
start_x, start_y
Integer. Starting reference coordinate; not a fixed range. If unsure, use 0, 0 -
start_color
Integer. Color value to search -
start_similarity
Integer, optional. 1~100. Default 100 -
dx*, dy*
Integer. Offset position relative to the start -
color*
Integer. Expected color at the offset -
similarity*
Integer, optional. -100~100. Default 100. Negative similarity means match if similarity is less than abs(value) -
global_similarity
Integer, optional. Used when a point's similarity is not specified. 1~100. Default 100 -
left, top, right, bottom
Integer, optional. Search region. Default full image
Returns
- x, y
Integer. Coordinate of the first matched structure. Returns -1, -1 if not found
Description
Use similarity mode to find the first position matching a multi-point color structure within the region
For offset mode usage, refer to screen.find_color
Example
img = screen.image()
x, y = img:find_color({
{ 0, 0, 0xec1c23},
{ 12, -3, 0xffffff, 85},
{ 5, -18, 0x00adee},
{ -1, -10, 0xffc823},
{ 2, -34, 0xa78217},
{ 12, -55, 0xd0d2d2},
}, 90, 0, 0, 100, 100)