ApplesauceOS
Read Markdown ↗Download .md

findColors

Find a pattern of color anchors.

js
findColors(options)

Arguments

ArgumentTypeMeaning
options.colorsarray[{color,x,y}, ...] or [[color,x,y], ...]; first offset must be (0,0). Remaining offsets are relative.
options.countnumberMaximum matches; default 10, 0 = all.
options.regionobject | arrayOptional {x,y,width,height} or [x,y,width,height] in native pixels.
options.tolerancenumberPer-channel difference 0..255; default 0.
options.rightToLeft, options.bottomToTopbooleanOptional scan directions; default false.
options.debugbooleanOptional saved debug image; default false.

Returns

[locations, null] or [null, errorString]. [] means no match.

Example

js
const [hits, error] = findColors({colors: [[0xFF0000, 0, 0], [0xFFFFFF, 10, 0]], count: 1});
if (error) throw new Error(error);
console.log(hits);

All JavaScript APIs · Automation playbook