Nebula using that you will just get the highest result of a single colored box instead of multiple overlayed boxes I think.
This is what I used to combine two colors
function FindHobgoblin: Boolean;
var
i, j, t: Integer;
ATPA: Array[0..1] of TPointArray;
Colors, Tol, Area: Array of Integer;
BoxSize: Array[0..1] of Integer;
HueMod, SatMod: Array of Extended;
TBox: Array[0..1] of TBox;
ClearBoxes: TBox;
ClearTPA: TPointArray;
begin
// Details of the gray & brown colors of Hobgoblins
Colors := [9411230, 4020585]
Tol := [28, 11]
HueMod := [0.23, 0.17]
SatMod := [0.20, 1.24]
Area := [MSCX-220, MSCY-100, MSCX+200, MSCY-35]
ClearTPA := TPAFromBox(IntToBox(240, 110, 285, 140));
SMART_ClearCanvasArea(IntToBox(Area[0]-2, Area[1]-2, Area[2]+2, Area[3]+2));
MarkTime(t);
for i:=0 to high(Colors) do
begin
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(HueMod[i], SatMod[i]);
if FindColorsSpiralTolerance(((MSX1+MSX2)/2), ((MSCY+MSY1)/2), ATPA[i], Colors[i], Area[0], Area[1], Area[2], Area[3], Tol[i]) then
begin
//WriteLn('Points: '+ToStr(ATPA[i])+'');
ClearTPAFromTPA(ATPA[i], ClearTPA);
WriteLn('Length: '+IntToStr(Length(ATPA[i]))+'');
if (Length(ATPA[i])<100) then
Exit;
TBox[i] := GetTPABounds(ATPA[i]);
BoxSize[i] := (TBox[i].x1 + TBox[i].y1 + TBox[i].x2 + TBox[i].y2);
SMART_DrawBoxEx(False, IntToBox(TBox[i].x1, TBox[i].y1, TBox[i].x2, TBox[i].y2), clRed);
end;
end;
for i:=0 to (high(Colors)-1) do
begin
for j:=0 to high(ATPA[i]) do
if NearbyPointInArray(ATPA[i][j], 1, ATPA[i+1]) then
begin
if TimeFromMark(t) < 1500 then
begin
MMouse(ATPA[i][j].x, ATPA[i][j].y, 0, 0);
if WaitUptextMulti(['tta', 'ack', 'obg', 'blin', 'Hobgoblin'], 100) then
begin
//WriteLn('Point: '+ToStr(ATPA[i][j])+'');
WriteLn('Clicked on a hobgoblin');
ClickMouse2(1);
Result:=True;
Exit;
end;
end else
begin
WriteLn('Too many attempts to find the hobgoblin, trying again soon');
Exit;
end;
end;
end;
end;
Standards are a bit off there lol, but it might give you some idea's.
Oh wait, according to that graphic he just wants to get the box with the biggest amount of color? Nebula's code will work for that as far as I can judge from the code alone.