Here is the function:
Simba Code:
function FindFairyRing(): TPoint;
const
COLOR = 4540484; //background color and tolerance
TOL = 86;
var
BackgroundTPA, BoxTPA, InverseTPA: TPointArray;
ATPA: T2DPointArray;
begin
if FindColorsTolerance(BackgroundTPA, COLOR, 0, 0, 300, 300, TOL) then //just change the coordinate to the mainscreen
begin
BoxTPA := TPAFromBox([0, 0, 300, 300]); //use the mainscreen box
InverseTPA := ClearTPAFromTPA(BoxTPA, BackgroundTPA);
ATPA := ClusterTPA(InverseTPA, 1);
FilterTPAsBetween(ATPA, 0, 5); //adjust these filters as needed
FilterTPAsBetween(ATPA, 100, 1000000);
ATPA := ClusterTPA(MergeATPA(ATPA), 20); //adjust cluster distance as needed
SortATPASize(ATPA, True);
if (Length(ATPA) < 1) then Exit;
Result := MedianTPA(ATPA[0]);
end;
end;
and here is the result:
(a random picture I found online)
You don't actually need more than one TPA variable, but I didn't want the logic to get too muddy.
This will work too:
Simba Code:
ATPA := ClusterTPA(ClearTPAFromTPA(TPAFromBox([0, 0, 300, 300]), BackgroundTPA), 1);