SRL Archive - SRL Suggestions

Two ColorFinding Funcs


m34tcode

2012-05-17 19:50:17

(*
FindMultipleColors
~~~~~~~~~~~

.. code-block:: pascal

function FindMultipleColors(var ATPA : T2DPointArray; Colors: TIntegerArray; SearchBox : TBox; Tolerance : Integer) : Boolean;

Returns the result of multiple calls of FindColorsTolerance in an ATPA

.. note::

Author: m34tcode
Last Modified: 5/17/12 by m34tcode

Example:

.. code-block:: pascal

FindMultipleColors(ATPA,[16777215,4539717],InvBox(5),10);
Smart_DrawDots(MergeATPA(ATPA));
*)
function FindMultipleColors(var ATPA : T2DPointArray; Colors: TIntegerArray; SearchBox : TBox; Tolerance : Integer) : Boolean;
var
I : Integer;
begin
Result := False;
SetArrayLength(ATPA,Length(Colors));
for I := 0 to High(Colors) do
begin
if FindColorsTolerance(ATPA[I],Colors[I],SearchBox.X1,SearchBox.Y1,SearchBox.X2,SearchBox.Y2,Tolerance) then
Result := True;
end;
end;

(*
FindMultipleColors
~~~~~~~~~~~

.. code-block:: pascal

function FindColorsMM(var ATPA : T2DPointArray; Colors : TIntegerArray; MinRadius,MaxRadius,Tolerance : Integer) : Boolean;

Returns the colors found within the minimap circle

.. note::

Author: m34tcode
Last Modified: 5/17/12 by m34tcode

Example:

.. code-block:: pascal

FindColorsMM(ATPA,[16777215,4539717],45,70,10);
Smart_DrawDots(MergeATPA(ATPA));
*)
function FindColorsMM(var ATPA : T2DPointArray; Colors : TIntegerArray; MinRadius,MaxRadius,Tolerance : Integer) : Boolean;
var
I : Integer;
begin
FindMultipleColors(ATPA,Colors,IntToBox(MMX1,MMY1,MMX2,MMY2),Tolerance);
for I := 0 to High(ATPA) do
begin
FilterPointsDist(ATPA[I],MinRadius,MaxRadius,MMCX,MMCY);
if not Result and (Length(ATPA[I]) > 0) then
Result := True;
end;
end;

Find Multiple colors is the same as findColors, except it will return the results of multiple calls in an ATPA.

FindColorsMM Will Return all colors found in just the minimap circle.

Usefull enough to be merged into the SRL include? I can commit and send a pull request if so

Brandon

2012-05-17 19:58:18

Iunno how useful that would be (TO ME) as I personally like to loop through my own arrays but one thing I definitely vote for is the parameters you have. By this I mean.. Instead of using X1, Y1, X2, Y2, All the finder functions should just take a TBox tbh. For that you get a +1 from me.

Runaway

2012-05-17 20:00:04

Perhaps make the result a TBooleanArray? Mine as well since it (the result) really has no use otherwise :P


function FindMultipleColors(var ATPA : T2DPointArray; Colors: TIntegerArray; SearchBox : TBox; Tolerance : Integer) : TBooleanArray;
var
I : Integer;
begin
SetArrayLength(ATPA,Length(Colors));
for I := 0 to High(Colors) do
begin
Result[I] := False;
if FindColorsTolerance(ATPA[I],Colors[I],SearchBox.X1,SearchBox.Y1,SearchBox.X2,SearchBox.Y2,Tolerance) then
Result[I] := True;
end;
end;


function FindColorsMM(var ATPA : T2DPointArray; Colors : TIntegerArray; MinRadius,MaxRadius,Tolerance : Integer) : TBooleanArray;
var
I : Integer;
begin
FindMultipleColors(ATPA,Colors,IntToBox(MMX1,MMY1,MMX2,MMY2),Tolerance);
for I := 0 to High(ATPA) do
begin
Result[I] := False;
FilterPointsDist(ATPA[I],MinRadius,MaxRadius,MMCX,MMCY);
if not Result and (Length(ATPA[I]) > 0) then
Result[I] := True;
end;
end;

m34tcode

2012-05-17 21:05:22

TBool is not a bad idea. I used the single boolean, and return val as paramater,, because that is how all the other funcs return. Figured it would be best to keep the same format :3.

Narcle

2012-05-17 22:21:25

/random m34tcode your at 666 posts

I believe the higher use of TBox's is being considered for SRL6, as you can imagine it's a major rework for the whole system otherwise it would be implemented now. >.>

Don't quote me, but if I work on it you'll be seeing my functions with TBox more.

m34tcode

2012-05-18 00:03:38

Think these are good srl funcs? or snippets, im kind of in between :3

euphemism

2012-05-18 00:27:17

One suggestion would be having an integer array for the tolerance parameter. I doubt you would want to use the same tolerance for every color.