SRL Archive - OSR Help

CountColorTolerance


Nebula

2012-07-03 17:54:46

Does CountColorTolerance use CTS 1 or 2? I would like to use this function to shorten up my code rather than making a TPA and getting the length of the TPA. That would save so many lines.

"Simba is completely open sourced blah blah blah" Then why can't I look at the code for half the functions I use?

Velvet Glam

2012-07-03 17:57:47

CountColorTolerance can use any tolerance speed, as any color function can do

simply call SetColorToleranceSpeed before the color finding

edit: u can look at the source for the functions u use?

Sirenia

2012-07-03 17:58:15

It isnt in the srl include so idk on how to answer that :O

Ashaman88

2012-07-03 17:59:13

http://docs.villavu.com/simba/scriptref/colourfinding.html#countcolortolerance

Nebula

2012-07-03 18:00:52

From: ashaman88
http://docs.villavu.com/simba/scriptref/colourfinding.html#countcolortolerance


I know what it does man. I need to know what CTS it uses.

Runaway

2012-07-03 18:34:06

From: Nebula
I know what it does man. I need to know what CTS it uses.


It uses whatever CTS you've set. CTS is independent of color-finding (unless it's a function with CTS built-in, of course; but most aren't). You can view the source code here:

https://github.com/MerlijnWajer/Simba

Go to Units -> MMLCore to find most of the common built-in Simba functions.

Brandon

2012-07-03 18:40:07


function TMFinder.CountColorTolerance(Color, xs, ys, xe, ye, Tolerance: Integer): Integer;
var
PtrData: TRetData;
Ptr: PRGB32;
PtrInc: Integer;
dX, dY, xx, yy: Integer;

compare: TCTSCompareFunction;
ctsinfo: TCTSInfo;
begin
Result := 0;
DefaultOperations(xs, ys, xe, ye);

dX := xe - xs;
dY := ye - ys;

PtrData := TClient(Client).IOManager.ReturnData(xs, ys, dX + 1, dY + 1);
Ptr := PtrData.Ptr;
PtrInc := PtrData.IncPtrWith;
result := 0;

ctsinfo := Create_CTSInfo(Color, Tolerance);
compare := Get_CTSCompare(Self.CTS);

for yy := ys to ye do
begin;
for xx := xs to xe do
begin
if compare(ctsinfo, Ptr) then
inc(result);
Inc(Ptr);
end;
Inc(Ptr, PtrInc)
end;

Free_CTSInfo(ctsinfo);
TClient(Client).IOManager.FreeReturnData;
end;

Uses the global CTS aka the current CTS before the function was called.

Wizzup?

2012-07-06 09:41:46

Read this: http://docs.villavu.com/simba/scriptref/colourfinding.html#colour-tolerance