How To Call It#
This is an object method: call it with a colon on a Region object created with Region(x, y, w, h), or Region() for the whole screen (region:<method>(...)). The global Region table does not have this method. Requires Macro Handler 1.0.51 or later.
When To Use It#
Use it when a script needs every patch of a colour at once, for example to count health-bar segments, pick the largest marker or tap each coloured dot, instead of calling region:findColor again and again with exclusions. Call Snap.screenRefresh() first when the screen may have changed. FindParam is not read: the second argument is an options table.
Parameters and Return#
color is a hex string such as "#FF0000", "#AARRGGBB" or "#F00", a list of up to 16 hex strings or colour assets matched together, Asset.color(...), or an HSV table { hMin, hMax, sMin, sMax, vMin, vMax } with hue in degrees and s and v from 0 to 1. Numbers, text assets and image assets are refused. options: tolerance (0-255, default 10), minArea (default 1), maxResults (1-256, default 32), connectivity (8 or 4), step (1-8 sampling stride; areas become estimates), sort ("area" or "position") and excludeRegion. x, y, w, h, cx and cy are in the macro's coordinates, while area and minArea count screen-capture pixels of the device running the macro and are not rescaled: on another resolution compare w and h instead. fill is the matched share of the box. The result is an empty table when nothing matches and nil for invalid arguments or a failed scan (System.lastScanError() says why).
Best Combined With#
Check for nil first, then loop over the rows: #blobs is the number of patches and, with sort = "area", blobs[1] is the largest. Tap a patch with click(Point(b.cx, b.cy)). Each call captures the screen once, so a polling loop should wait between calls.