SRL Archive - SRL Archives

ColorNearMouse / ColorNearMouse2


Ares

2006-08-18 18:17:43


Function ColorNearMouse(x, y, color, distance: integer):Boolean;
var c,v,cv1,cv2,cv3,cv4: integer;
begin
GetMousePos(c,v);
cv1:=c+distance;
cv2:=c-distance;
cv3:=v+distance;
cv4:=v-distance;
if(findcolor(x,y,color,cv1,cv3,cv2,cv4))then
begin
result:=true
end
if(not findcolor(x,y,color,cv1,cv3,cv2,cv4))then
begin
result:=false
end
end;


Function ColorNearMouse2(x, y, color, distance, tol: integer):Boolean;
var c,v,cv1,cv2,cv3,cv4: integer;
begin
GetMousePos(c,v);
cv1:=c+distance;
cv2:=c-distance;
cv3:=v+distance;
cv4:=v-distance;
if(findcolorspiraltolerance(x, y, color, cv1, cv3, cv2, cv4, tol))then
begin
result:=true
end
if(not findcolorspiraltolerance(x, y, color, cv1, cv3, cv2, cv4, tol))then
begin
result:=false
end
end;

Freddy1990

2006-08-18 19:03:16

edit: hmm, nvm, looks ok
edit2:
isn't it supposed to be:
function ColorNearMouse(var x, y: Integer; color, distance: Integer): Boolean;
function ColorNearMouse2(var x, y: Integer; color, distance, tol: Integer): Boolean;
?

WT-Fakawi

2006-08-18 19:06:03

IMHO you miscalculate distance?

cv1:=c+distance;
cv2:=c-distance;
cv3:=v+distance;
cv4:=v-distance;
if(findcolor(x,y,color,cv1,cv3,cv2,cv4))then
shouldnt that be:


cv1:=c+distance;
cv2:=c-distance;
cv3:=v+distance;
cv4:=v-distance;
if(findcolor(x,y,color,cv2,cv4,cv1,cv3))then

This one is I think equal to yours:

Function ColorNearMouse(color, dist: integer):Boolean;
var CNMx, CNMy, DUMx, DUMy: integer;
begin
GetMousePos(CNMx,CNMy);
result:= findcolor(DUMx, DUMy, color, CNMx-dist, CNMy-dist, CNMx+dist, CNMy+dist);
end;

or make it return the coords maybe?

Anyway, good job! thanks for your addition…

Freddy1990

2006-08-18 19:10:28

Oh yeah now i c… tha x and y don't need to be put in :rolleyes:
Oh well, 1 am, my mind stopped working hours ago

WhiteShadow

2006-08-22 19:30:26

Nice one, Ares. Probably find a use for this. :)

Yea your right, Fawki. His would of created an unaccurate box.