Wanted
2007-08-03 22:44:18
Works very well if you enter the correct input (Don't get confused about the the input, just pretend like they are all integers, also, this website keeps messing with my standards! IT'S A CAPITAL I in !)
I've been using this a lot lately in combination with Dynamic DTMs and more and it's working extremely well :)
Edit: Changed it to FindColorsSpiral but no extra input is needed.
Edit: Very very minor change in the great than -> greater than or equal to ect..
I've been using this a lot lately in combination with Dynamic DTMs and more and it's working extremely well :)
Edit: Changed it to FindColorsSpiral but no extra input is needed.
Edit: Very very minor change in the great than -> greater than or equal to ect..
// * function AutoColorByCount(GenericColor, MinCount, MaxCount: LongWord; X1, Y1, X2, Y2: Word; Tolerance, CTS: Byte): LongWord; // by IceFire908.
{*******************************************************************************
function AutoColorByCount(GenericColor, MinCount, MaxCount: LongWord; X1, Y1, X2, Y2: Word; Tolerance, CTS: Byte): LongWord;
by: IceFire908.
Description: Finds an array of colors based on a generic color, an area, a tolerance,
and a color tolerance speed, then returns a color based on a minimum and maximum
amount of that color that can be present.
*******************************************************************************}
function AutoColorByCount(GenericColor, MinCount, MaxCount: LongWord; X1, Y1, X2, Y2: Word; Tolerance, CTS: Byte): LongWord;
var
TPA: TPointArray;
IA: array of Integer;
Count, I: LongWord;
begin
ColorToleranceSpeed(CTS);
FindColorsSpiralTolerance((X1 + X2) div 2, (Y1 + Y2) div 2, TPA, GenericColor, X1, Y1, X2, Y2, Tolerance);
IA := GetColors(TPA);
for I := 0 to (GetArrayLength(IA) - 1) do
begin
Count := CountColor(IA[I], X1, Y1, X2, Y2);
if ((Count <= MaxCount) and (Count >= MinCount)) then
begin
Result := IA[I];
ColorToleranceSpeed(1);
Exit;
end;
end;
WriteLn('ERROR: AutoColorByCount failed!');
ColorToleranceSpeed(1);
end;