n3ss3s
2007-12-20 06:24:16
this small autocolor proc.
Now, lets say that you are finding a color.
Every succesfull time found you save the color in an array.
Now, here is the thing - you don't do for loops for finding the color like
FindColor(X, Y, c, x1, y1, x2, y2)
Lets say, every fifth time a color is succesfully found, you do
"UpdateCFromArray(RefColor, ColorsArray);"
and voila, you have the color closest to RefColor.
:) Simple, effective.
Now, lets say that you are finding a color.
Every succesfull time found you save the color in an array.
Now, here is the thing - you don't do for loops for finding the color like
FindColor(X, Y, c, x1, y1, x2, y2)
Lets say, every fifth time a color is succesfully found, you do
"UpdateCFromArray(RefColor, ColorsArray);"
and voila, you have the color closest to RefColor.
:) Simple, effective.
Procedure UpdateCFromArray(Var Color: Integer; Colors: TIntegerArray);
Var
I, LTol, C, N, L: Integer;
Begin
LTol := iAbs(Color - Colors[0]);
N := 0;
L := High(Colors);
For I := 0 To L Do
Begin
C := iAbs(Color - Colors[i]);
If C < LTol Then
Begin
N := i;
LTol := c;
End;
End;
Color := Colors[n];
End;