SCAR Code:
program New;
{.include srl/srl.scar}
procedure XYZtoLab(X, Y, Z : Extended; var L, A, B : Extended);
begin
try
L := 10 * Sqrt( Y );
A := 17.5 * ((( 1.02 * x) - y) / Sqrt( Y ));
B := 7 * ((Y - (0.847 * Z)) / Sqrt( Y ));
except
Writeln('ERROR: Math ERROR');
end;
end;
procedure LabToXYZ(L, A, B : Extended; var X, Y, Z : Extended);
begin
try
Y := Pow(L / 10, 2);
X := ((A / 17.5 * L / 10) + Y) / 1.02;
Z := -((B / 7 * L / 10) - Y) / 0.847;
except
Writeln('ERROR: Math ERROR');
end;
end;
procedure ColorToLab(Color : Integer; var L, A, B : Extended);
var
X, Y, Z : Extended;
begin
ColortoXYZ(Color, X, Y, Z);
XYZtoLab(X, Y, Z, L, A, B);
end;
function LabToColor(L, A, B : Extended) : Integer;
var
X, Y, Z : Extended;
begin
LabToXYZ(L, A, B, X, Y, Z);
Result := XYZtoColor(X, Y, Z);
end;
function GetFallyRoadColor : Integer;
var
P : TPointArray;
i, Color, Sx, Sy : integer;
L, A, B : Extended;
begin
sx := MMCX;
sy := MMCY;
If (FindColorSpiralTolerance(sx, sy, 6518140, MMX1, MMY1, MMX2, MMY2, 70)) then
If (rs_OnMinimap(sx, sy)) then
begin
FindColorsSpiralTolerance(sx, sy, P, 6518140, MMX1, MMY1, MMX2, MMY2, 70);
for i := 0 to GetArrayLength(P)-1 do
begin
If (rs_OnMinimap(P[i].x, P[i].y)) then
begin
Color := GetColor(P[i].x, P[i].y);
if (Color < 1) then Color := 1;
ColortoLab(Color, L, A, B);
If (B < 0.0) and (B > -8.0) and (A < 25)then
begin
Result := Color;
Writeln('Found Fally Road Color = ' + IntToStr(Result));
Exit;
end;
end;
end;
end;
end;
begin
SetupSRL;
FindRS;
ActivateClient;
Wait(1000);
GetFallyRoadColor;
//Writeln(inttostr(GetBankColor));
end.