Sir R. M8gic1an
2010-05-27 08:11:02
{******************************************************************************}
{ procedure MSI_SortColors(var Colors: tIntegerArray; col: Integer); }
{ By: Blumblebee }
{ Description: Sorts an array of colors }
{******************************************************************************}
procedure MSI_SortColors(var Colors: tIntegerArray; col: Integer);
var
tempB: tIntegerArray;
Tol: ShortInt;
I: Integer;
timer, L: LongInt;
begin
timer := getsystemtime;
tempB := Colors;
SetArrayLength(Colors, 0);
Tol := 0;
while Length(Colors) < (Length(tempB)/2 or 5) do //huh?
begin
if Getsystemtime-timer > 100 then Break; //why this?
for i := 0 to High(tempB) do
begin
if SimilarColors(tempB[i], col, Tol) then
begin
L := GetArrayLength(Colors);
SetArrayLength(Colors, L+1);
Colors[L] := tempB[i];
end;
if Tol > 10 then Break;
Inc(Tol);
end;
end;
end;
This line specifically leaves me very curious:
while Length(Colors) < (Length(tempB)/2 or 5) do
2 or 5 ?
As for the timer breaker, I don't find it necessary as you already have the tolerance breaker and the length breaker. The timer if anything will mess it up.
~RM