SRL Archive - SRL Archives

FindColorEx


ollie

2006-05-28 04:10:18

This Function Was in GenoDemoNs Ub3r Fighter and i didnt see it in SRL

maybe its useful?

function findcolorex(cmc,l,u,r,d,rl,ru,rr,rd:integer):boolean;
var
x1,x2,x3,x4,y1,y2,y3,y4,xxx,yyy,d1,d2,d3,d4:integer ;
b1,b2,b3,b4:boolean;
begin
xxx:=(rl+rr)/2;
yyy:=(ru+rd)/2;
IF ((findcolorspiraltolerance(x1,y1,cmc,l,u,r,ru,tol)) or
(findcolorspiraltolerance(x2,y2,cmc,l,ru,rl,rd,tol))or
(findcolorspiraltolerance(x3,y3,cmc,rr,ru,r,rd,tol))or
(findcolorspiraltolerance(x4,y4,cmc,l,rd,r,d,tol)))then
begin
b1:=false;
b2:=false;
b3:=false;
b4:=false;
IF (findcolorspiraltolerance(x1,y1,cmc,l,u,r,ru,tol)) then b1:=true;
IF (findcolorspiraltolerance(x2,y2,cmc,l,ru,rl,rd,tol)) then b2:=true;
IF (findcolorspiraltolerance(x3,y3,cmc,rr,ru,r,rd,tol)) then b3:=true;
IF (findcolorspiraltolerance(x4,y4,cmc,l,rd,r,d,tol)) then b4:=true;
d1:=(xxx-x1)*(xxx-x1)+(yyy-y1)*(yyy-y1);
d2:=(xxx-x2)*(xxx-x2)+(yyy-y2)*(yyy-y2);
d3:=(xxx-x3)*(xxx-x3)+(yyy-y3)*(yyy-y3);
d4:=(xxx-x4)*(xxx-x4)+(yyy-y4)*(yyy-y4);
result:=false;
If ((d1<d2)and(d1<d3)and(d1<d4)and(b1)) then
begin
x:=x1;
y:=y1;
result:=true;
end;
If ((d2<d1)and(d2<d3)and(d2<d4)and(b2)) then
begin
x:=x2;
y:=y2;
result:=true;
end;
If ((d3<d2)and(d3<d1)and(d3<d4)and(b3)) then
begin
x:=x3;
y:=y3;
result:=true;
end;
If ((d4<d2)and(d4<d3)and(d4<d1)and(b4)) then
begin
x:=x4;
y:=y4;
result:=true;
end;

end;
end;

Jagex_Fagex

2006-05-28 04:25:52

hm, did you ask before ripping?

ollie

2006-05-28 08:26:35

From: Jagex_Fagex
hm, did you ask before ripping?

Ripping?

i TOLD you i got it from there, its merely too look at, i think its better then the method SRL uses now

Wizzup?

2006-05-28 08:36:29

Ouch, apply standards please. :)

Normally I do not care about standards, but I am unable to follow this at the moment.. haha.

Krazy_Meerkat

2006-05-28 08:51:07

[php]function findcolorex(cmc, l, u, r, d, rl, ru, rr, rd : integer) : boolean;
var
x1, x2, x3, x4, y1, y2, y3, y4, xxx, yyy, d1, d2, d3, d4 : integer;
b1, b2, b3, b4 : boolean;
begin
xxx := (rl + rr) / 2;
yyy := (ru + rd) / 2;
if ((findcolorspiraltolerance(x1, y1, cmc, l, u, r, ru, tol)) or
(findcolorspiraltolerance(x2, y2, cmc, l, ru, rl, rd, tol)) or
(findcolorspiraltolerance(x3, y3, cmc, rr, ru, r, rd, tol)) or
(findcolorspiraltolerance(x4, y4, cmc, l, rd, r, d, tol))) then
begin
b1 := false;
b2 := false;
b3 := false;
b4 := false;
if (findcolorspiraltolerance(x1, y1, cmc, l, u, r, ru, tol)) then b1 := true;
if (findcolorspiraltolerance(x2, y2, cmc, l, ru, rl, rd, tol)) then b2 := true;
if (findcolorspiraltolerance(x3, y3, cmc, rr, ru, r, rd, tol)) then b3 := true;
if (findcolorspiraltolerance(x4, y4, cmc, l, rd, r, d, tol)) then b4 := true;
d1 := (xxx - x1) * (xxx - x1) + (yyy - y1) * (yyy - y1);
d2 := (xxx - x2) * (xxx - x2) + (yyy - y2) * (yyy - y2);
d3 := (xxx - x3) * (xxx - x3) + (yyy - y3) * (yyy - y3);
d4 := (xxx - x4) * (xxx - x4) + (yyy - y4) * (yyy - y4);
result := false;
if ((d1 < d2) and (d1 < d3) and (d1 < d4) and (b1)) then
begin
x := x1;
y := y1;
result := true;
end;
if ((d2 < d1) and (d2 < d3) and (d2 < d4) and (b2)) then
begin
x := x2;
y := y2;
result := true;
end;
if ((d3 < d2) and (d3 < d1) and (d3 < d4) and (b3)) then
begin
x := x3;
y := y3;
result := true;
end;
if ((d4 < d2) and (d4 < d3) and (d4 < d1) and (b4)) then
begin
x := x4;
y := y4;
result := true;
end;
end;
end;[/php]

Jagex_Fagex

2006-05-29 04:53:44

well, i know you said you did.. but it should be in that usefull snippets part, and i asked because some people don't like it when you use their code, even if you credit them.