SRL Archive - SRL Archives

AutoColorByCount


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..

// * 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;

Bobarkinator

2007-08-03 22:48:15

Good work, but why use byte's and longwords?

Wanted

2007-08-03 22:56:14

From: bobarkinator
Good work, but why use byte's and longwords?


Faster, less memory usage, avoids some errors you would get with negative numbers.

Why not use them?

n3ss3s

2007-08-04 05:15:56

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.


GOOD FHKING WORK BUT I MADE TOTALLY SAME THING YESTERDAY without knowing u made one… Except bob told me when I told him about my cool function when it was almost ready lol….. Lolmg..
Except mine is for object finding and your autocoloring..