SCAR Code:
function FindTreeColor: Integer;
var
TPA, TestTPA: TPointArray;
ATPA: T2DPointArray;
H, S, L: Extended;
I, R, G, B, Hi, TestColor, blkListHi: Integer;
TreeColorsBlackList: TIntegerArray;
begin
if FindMMColorsSpiralTolerance(TPA, 1730099, 70) then
begin
Hi := High(TPA);
For I := 0 to Hi do
begin
TestColor := GetColor(TPA[i].x, TPA[i].y);
if not InIntArray(TreeColorsBlackList, TestColor) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
if InRange(R - B, -10, 50) then
if InRange(R - G, -75, -30) then
if InRange(G - B, 50, 88) then
if (L < 31.5) then
if (GetColor(TPA[i].x - 1, TPA[i].y) = TestColor) then
if (GetColor(TPA[i].x, TPA[i].y + 1) = TestColor) then
if (GetColor(TPA[i].x, TPA[i].y - 1) = TestColor) then
if FindMMColorsSpiralTolerance(testTPA, TestColor, 0) then
begin
ATPA := TPAtoATPAEx(TestTPA, 11, 10);
if (not InRange(Length(ATPA[0]), 21, 28)) then
if (Length(ATPA[0]) < 30) then
if (not InRange(Length(ATPA[0]), 8, 10)) then
begin
srl_Warn('FindTreeColor', 'TreeColor = ' + IntToStr(TestColor), warn_Debug);
Result := TestColor;
Exit;
end else
if (L > 24) then
begin
blkListHi := High(TreeColorsBlackList);
SetLength(TreeColorsBlackList, blkListHi + 2);
TreeColorsBlackList[blkListHi + 1] := TestColor;
end;
end;
end;
end;
end;
srl_Warn('FindTreeColor', 'Could''t find TreeColor', warn_Debug);
Result := -1;
end;