ApplesauceOS
Read Markdown ↗Download .md

searchColor

Find pixels matching a color.

js
searchColor(options)

Arguments

ArgumentTypeMeaning
options.colornumberRGB integer, such as 0xFF0000.
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]; locations are {x,y} in native pixels.

Example

js
const [hits, error] = searchColor({color: 0xFF0000, count: 1, tolerance: 8});
if (error) throw new Error(error);
console.log(hits);

All JavaScript APIs · Automation playbook