# Tikz: Finding intersection of Brownian motion and circle

I'm trying to draw a two-dimensional Brownian motion started in a circle and now want to label the first exit time of the motion:

\documentclass[parskip]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through,backgrounds}

\begin{document}
\newcommand{\Emmett}[5]{% points, advance, rand factor, options, end label, name
\draw[#4] (0,0)
\foreach \x in {1,...,#1} node(#6)
{   -- ++(rand*#2,rand*#3)
}
node[right] {#5};
}

\begin{tikzpicture}
\coordinate [label=left:$x$] (x) at (0,0);
\coordinate [] (y) at (1,1);

\node (D) [name path=D,draw,circle through=(y),label=left:$D$] at (x) {};
\Emmett{300}{0.2}{0.2}{red}{a}{b};

\end{tikzpicture}
\end{document}


I guess it would be pretty easy with "intersection", if I could name the Brownian motion, but I don't really know how to do that. (Sorry, complete beginner in tikz...)
I'd appreciate any help.

You need to also apply a name path to the Brownian path and find intersections between both paths.

I could do it using the complete command inside the tikzpicture but not using the macro. Probably because the name inside the macro is not public outside, but I'm not sure.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc,intersections,through,backgrounds}

\begin{document}

\begin{tikzpicture}
\coordinate [label=left:$x$] (x) at (0,0);
\coordinate [] (y) at (1,1);

\node (D) [name path=D,draw,circle through=(y),label=left:$D$] at (x) {};
%\Emmett{300}{0.2}{0.2}{red}{a}{b};
\draw[red, name path=emmet] (0,0) \foreach \x in {1,...,300}{--++(rand*0.2,rand*0.2)};

\fill[green, name intersections={of= emmet and D}] (intersection-1) circle (2pt);
\end{tikzpicture}
\end{document}