Hi,
I want to share this Lape-style class, which I've created some time ago to make the process of scripting color finding functions more handy and faster. I personally dislike writting too much redundant characters, such as long function names, wide arrays of parameters, semi-repetitive code etc... This include makes life simpler.
Yes, I know there is already a little similar solution in SRL-6 ,but I don't understand why ColorSettings( cts ,hue ,sat) are separated from color and tolerance. In practice I never share the same (cts,hue,sat) values with different objects with another color or tolerance. So here all unique properties: color, tolerance, CTS, hue, sat, cts3mod of one object are packed into one container.
Some pros:
- Short names, less text
- Object oriented
- No more:
Simba Code:
SetColorSpeed2Modifiers(0.44, 1.62);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 1013212, MSX1, MSY1, MSX2, MSY2, 8); // for what I've been searching here month ago ??!!
- If object's color has changed, you have only one line to fix.
Constructor:
Simba Code:
procedure TCol.Create(_Col, _Tol, _CTS : integer; _hue, _sat: extended);
procedure TCol.Create(_Col, _Tol, _CTS : integer); overload;
procedure TCol.Create(_Col, _Tol, _CTS : integer; _cts3mod : extended); overload;
procedure TCol.Create(_Col : integer); overload;
Example:
Simba Code:
MobCol.Create(16757115, 5 , 2 , 0.5 , 0.3);
MobCol.FindTPA(TPA, MSBox);
OR
Simba Code:
BlackCol.Create(0);
BlackCol.FindTPA(TPA); // search inside whole client
Functions :
Simba Code:
function TCol.FindTPA (var TPA:TPointArray; Box: TBox ): boolean;
function TCol.CountColor (Box: TBox ): integer;
function TCol.FindArea (var x, y :integer; MinArea: integer; Box: TBox ): boolean;
function TCol.WaitCountColor ( Relation: string; Number, WaitTime, MaxTime:integer; Box : TBox) : boolean;
function TCol.WaitCountColor ( RangeMin, RangeMax, WaitTime, MaxTime :integer; Box : TBox ) : boolean;
and their overloaded versions...
The last two versions of WaitCountColor() need an explanation:
First version uses a relational operator ( "= "<>" ">" "<" "<=" ">=" ). So if you want to command:
Wait for max of 10000 ms with intervals of 200 ms until you see equal or less than 3333 pixels of defined TCol on MainScreen.
Simba Code:
MyCol.WaitCountColor ( '<=' ,3333 , 10000 , 200 , mainscreen.getBounds() );
Second one simply uses a range check.
Simba Code:
MyCol.WaitCountColor ( 0 ,3333 , 10000 , 200 , mainscreen.getBounds() );
If you have an idea on any function which should be added here or you've noticed any bug - please post it