Simba Code:
program AutoColor;
{$I SRL\SRL.simba}
function RedBox : Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 1.75);
FindColorsSpiralTolerance(640, 512, arP, 16043446, 0, 0, 1280, 1024, 8);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 60.28) and (H <= 60.38) and (S >= 68.97) and (S <= 90.26) and (L >= 74.69) and (L <= 91.98) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 43.15) and (X <= 74.37) and (Y >= 44.73) and (Y <= 78.30) and (Z >= 84.94) and (Z <= 104.14) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
function LazIcon : Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(3);
SetColorSpeed3Modifiers(1,8);
FindColorsSpiralTolerance(640, 512, arP, 16043446, 0, 0, 1280, 1024, 8);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 60.28) and (H <= 60.38) and (S >= 68.97) and (S <= 90.26) and (L >= 74.69) and (L <= 91.98) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 43.15) and (X <= 74.37) and (Y >= 44.73) and (Y <= 78.30) and (Z >= 84.94) and (Z <= 104.14) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;
ColorToleranceSpeed(tmpCTS);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
begin
SetupSRL;
RedBox;
LazIcon;
end.
Simba Code:
program FindObjects;
{$I SRL\SRL.simba}
var
x, y: Integer;
function RedBox(var x,y: integer) : Integer;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.08, 1.75);
if not(FindColorsTolerance(arP, 16043446, MSX1, MSY1, MSX2, MSY2, 8)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 60.28) and (H <= 60.38) and (S >= 68.97) and (S <= 90.26) and (L >= 74.69) and (L <= 91.98) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 43.15) and (X <= 74.37) and (Y >= 44.73) and (Y <= 78.30) and (Z >= 84.94) and (Z <= 104.14) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;
function LazIcon(var x,y: integer) : Integer;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(3);
SetColorSpeed3Modifiers(1,8);
if not(FindColorsTolerance(arP, 16043446, MSX1, MSY1, MSX2, MSY2, 8)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 60.28) and (H <= 60.38) and (S >= 68.97) and (S <= 90.26) and (L >= 74.69) and (L <= 91.98) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 43.15) and (X <= 74.37) and (Y >= 44.73) and (Y <= 78.30) and (Z >= 84.94) and (Z <= 104.14) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;
begin
SetupSRL;
LazIcon(x,y);
LazIcon(x,y);
end.