SCAR Code:
function FindClosestColor(var cx,cy : integer; Color, OriginX, OriginY, MaxDist, Tol : integer): Boolean;
var
CPX, CPY, PX, PY, Dist : integer;
begin
Dist := MaxDist+1;
For PX := OriginX-MaxDist to OriginX+MaxDist do
begin
For PY := OriginY-MaxDist to OriginY+MaxDist do
begin
If Distance(PX,PY,OriginX,OriginY) < Dist then
begin
If SimilarColors(GetColor(PX, PY), Color, Tol) then
begin
CPX := PX;
CPY := PY;
Dist := Distance(PX,PY,OriginX,OriginY);
MaxDist := Dist;
end;
end;
end;
end;
If CPX <> 0 then
begin
cx := CPX;
cy := CPY;
result := True;
end else
begin
result := False;
end;
end;
I wrote this function. basically you give it an origin point, and it returns the closest colored point within tolerance range to the origin. (tested it in paint works nicely). I dont know if a function like this already exists (i checked the srl and scar manuals didnt see one). tell me what you think
and make sure to give me credits if you use it
-it returns the closest point within a distance of the x,y. it works in a circle