SCAR Code:
function GetClosest(RGB: string; ClosestTo, x1, y1, x2, y2, MaxAdd: Integer): Integer;
var
I, C1, C2, R, G, B, TempC, x, y: Integer;
var
TempB: Boolean;
begin
Result := 0;
ColorToRGB(ClosestTo, R, G, B);
for I := 1 to 2 do // 1 = Up, 2 = Down
begin
repeat
case RGB of
'R': begin
case I of
1: begin
TempC := RGBToColor(R, G, B);
if(not(FindColor(x, y, TempC, x1, y1, x2, y2)))then
begin
Inc(R);
end;
end;
2: begin
TempC := RGBToColor(R, G, B);
if(not(FindColor(x, y, TempC, x1, y1, x2, y2)))then
begin
Dec(R);
end;
end;
end;
'G': begin
case I of
1: begin
TempC := RGBToColor(R, G, B);
if(not(FindColor(x, y, TempC, x1, y1, x2, y2)))then
begin
Inc(G);
end;
end;
2: begin
TempC := RGBToColor(R, G, B);
if(not(FindColor(x, y, TempC, x1, y1, x2, y2)))then
begin
Dec(G);
end;
end;
end;
'B': begin
case I of
1: begin
TempC := RGBToColor(R, G, B);
if(not(FindColor(x, y, TempC, x1, y1, x2, y2)))then
begin
Inc(B);
end;
end;
2: begin
TempC := RGBToColor(R, G, B);
if(not(FindColor(x, y, TempC, x1, y1, x2, y2)))then
begin
Dec(B);
end;
end;
end;
end;