SRL Archive - Help and Support

how do findcolor/dtm/bmp functions work?


drizzt

2008-04-04 19:58:01

i just thought, it's a procedure that returns the two vars, typo XD

i was thinking about making like a finddtms procedure, that will store to a tpointarray, but i can't really tell by the way it finds things how it works.

so my question is, does it find starting from the top left corner like a spiral? or like find from the highest occurance of the color/dtm/bmp?

JuKKa

2008-04-05 03:52:46

starts from 0, 0

or actually x1, y1 and ends at x2, y2

drizzt

2008-04-05 08:59:40

ok, so it's kinda like a spiral from x1, y1?

Negaal

2008-04-05 10:58:47

Actually no…when spiral then it has something to do with some hard math…

Usual findcolor, findcolortolerance etc, do like JuKKa said.

sec.

Might be useful?

From: Negaal
I think the one whats built in scar or SRL plugins looks like this:

program Lolol;

function FindTPA(var TPA : TPointArray; Color, x1, y1, x2, y2, tolerance : integer) : boolean;
var
x, y, c : integer;
begin
SetArraylength(tpa,(x2-x1)*(y2 - y1))
for y:=y1 to y2 do
for x:=x1 to x2 do
if similarcolors(getcolor(x,y), color, tolerance) then
begin
tpa[c].x := x;
tpa[c].y := y;
inc(c)
end;
SetArrayLength(TPA, C)
Result := Length(tpa) > 0;
end;

var
tpa : tpointarray;
i, t : integer;

begin
t := getsystemtime;
findtpa(tpa, 255, 0, 0, 100, 100, 0)
writeln(inttostr(getsystemtime - t));
if length(tpa) > 0 then
for i:=0 to high(tpa) do
begin
movemousesmooth(tpa[i].x,tpa[i].y);
wait(100);
end;
end.

Because it's in script it's very slow. it took me almost 300 ms to scar 100 * 100 area.

I hope you can understand what function does.

Edit, to test, do draw something with red, you'll see it moves trough all the red pixels. note that you have to set you're x2 and y2.


All other color finding procedures look similar to this I think, instead of saving it to array it just breaks, and outputs last x and y.

About dtm's, bmp's and spiral searching I don't got no idea..something with math and logic..what I can never understand…