TikZ - "Circled" arrow

UPDATED: New version supporting styles, and new example:

This command can be useful:

\def\circledarrow#1#2#3{ % #1 Style, #2 Center, #3 Radius
\draw[#1,->] (#2) +(80:#3) arc(80:-260:#3);
}

It can be used as part of a Tikz picture like this:

\begin{tikzpicture}
\node (text) {$n$ times};
\circledarrow{ultra thick, gray}{text}{1cm};
\end{tikzpicture}

Result


My solution provides

  • a new node shape circle arrow,
  • three keys that work exactly like the keys for the arc operator:
    • /qrr/circle arrow/start angle,
    • /qrr/circle arrow/end angle,
    • /qrr/circle arrow/delta angle,
  • and a key /qrr/circle arrow/arrows that sets the arrows for the arc.

I have also added a few styles the pre-set the direction and the open part of the circle. Hopefully they are self-explanatory (see the example below).

Code

\documentclass[tikz,border=4pt]{standalone}
\usetikzlibrary{arrows,matrix}
\makeatletter
\tikzset{
    /qrr/circle arrow/.cd,
    start angle/.initial={},
    delta angle/.initial={},
    end angle/.initial={},
    arrows/.estore in=\qrr@ca@arrow,
    arrows=-
}
\pgfdeclareshape{circle arrow}{
    \inheritsavedanchors[from=circle] \inheritanchorborder[from=circle]
    \inheritanchor[from=circle]{north}      \inheritanchor[from=circle]{north west}
    \inheritanchor[from=circle]{north east} \inheritanchor[from=circle]{center}
    \inheritanchor[from=circle]{west}       \inheritanchor[from=circle]{east}
    \inheritanchor[from=circle]{mid}        \inheritanchor[from=circle]{mid west}
    \inheritanchor[from=circle]{mid east}   \inheritanchor[from=circle]{base}
    \inheritanchor[from=circle]{base west}  \inheritanchor[from=circle]{base east}
    \inheritanchor[from=circle]{south}      \inheritanchor[from=circle]{south west}
    \inheritanchor[from=circle]{south east}
    \backgroundpath{
        \pgfkeysgetvalue{/qrr/circle arrow/start angle}\qrr@ca@s
        \pgfkeysgetvalue{/qrr/circle arrow/end angle}\qrr@ca@e
        \pgfkeysgetvalue{/qrr/circle arrow/delta angle}\qrr@ca@d
        \ifx\qrr@ca@s\pgfutil@empty%
            \pgfmathsetmacro\qrr@ca@s{\qrr@ca@e-\qrr@ca@d}%
        \else
            \ifx\qrr@ca@e\pgfutil@empty%
                \pgfmathsetmacro\qrr@ca@e{\qrr@ca@s+\qrr@ca@d}%
            \fi%
        \fi
        \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfpointpolar{\qrr@ca@s}{\radius}}}%
        \pgfpatharc{\qrr@ca@s}{\qrr@ca@e}{\radius}%
        \pgfkeys{/tikz/arrows/.expand once=\qrr@ca@arrow}%
    }
}
\makeatother
\tikzset{% the first two styles are internal, they do not work alone!
    turn left/.style={/tikz/shape=circle arrow,/qrr/circle arrow/arrows=->,/qrr/circle arrow/delta angle=340},
    turn right/.style={/tikz/shape=circle arrow,/qrr/circle arrow/arrows=<-,/qrr/circle arrow/delta angle=340},
    turn left north/.style  = {/tikz/turn left,  /qrr/circle arrow/start angle=100} ,
    turn left east/.style   = {/tikz/turn left,  /qrr/circle arrow/start angle=10},
    turn left south/.style  = {/tikz/turn left,  /qrr/circle arrow/start angle=280},
    turn left west/.style   = {/tikz/turn left,  /qrr/circle arrow/start angle=190},
    turn right north/.style = {/tikz/turn right, /qrr/circle arrow/start angle=100} ,
    turn right east/.style  = {/tikz/turn right, /qrr/circle arrow/start angle=10},
    turn right south/.style = {/tikz/turn right, /qrr/circle arrow/start angle=280},
    turn right west/.style  = {/tikz/turn right, /qrr/circle arrow/start angle=190},
}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,draw=none,row sep=1em,column sep=1em,
    every node/.style={draw=gray,ultra thick, inner sep=.5em,font=$n$ times}
] (m) {
    |[turn left north]|  & |[turn left east]|   \\
    |[turn left west]|   & |[turn left south]|  \\
    |[turn right north]| & |[turn right east]|  \\
    |[turn right west]|  & |[turn right south]| \\
};
\end{tikzpicture}
\end{document}

Output

enter image description here


Just like this, with appropriates values:

\draw[->,>=latex'] (pointA) arc[radius=1cm,start angle=0,delta angle=270];