We can measure the polygon node (or any other node when arcs around/anchor
is set to a proper anchor) and use that measurement for the drawing of a few arc
s around it.
The \ifnum
in edge node
makes sure that we only put the angle once in our diagram. With the value key arcs around/test
you can specify one angle that shortens the arcs a bit.
The value of arcs around/sep
will be added to the measured radius.
They main keys are arcs around/a
(the list of start angles) and arcs around/d
the delta angle.
Code
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc,shapes.geometric,matrix,arrows.meta,bending}
\begin{document}
\begin{tikzpicture}[
arcs around/.code=\pgfqkeys{/tikz/arcs around}{#1},
arcs around={
.search also=/tikz,
a/.initial=0,
d/.initial=180,
test/.initial=180,
sep/.initial=1pt,
anchor/.initial=corner 1,
node/.style={
shape=rectangle, inner sep=+.1666em, auto, swap,
font=\scriptsize, node contents={$\pgfmathprintnumber{#1}^\circ$}
},
arc/.style n args={3}{
% #1 = counter, #2 = start angle, #3 = delta angle
->, draw, to path={arc[start angle=#2]\tikztonodes},
edge node/.expand once={\ifnum#1=1 node[arcs around/node=#3]\fi}
}
},
arcs around node/.style={
% #1 = list of start angles, #2 = delta angle (and text), #3 = mand. options
append after command={
% calculate radius of that circle
[arcs around={#1}]
let \p{circle} = ($(\tikzlastnode.\pgfkeysvalueof
{/tikz/arcs around/anchor})-(\tikzlastnode.center)$),
\n{radius} =
{veclen(\p{circle})+\pgfkeysvalueof{/tikz/arcs around/sep}},
\n{delta} = {\pgfkeysvalueof{/tikz/arcs around/d}} in % shortcut
% common values
[radius=\n{radius},
delta angle={\n{delta}-sign(\n{delta})*(abs(\n{delta})==
\pgfkeysvalueof{/tikz/arcs around/test}?4:0)}]
% draw arc for every angle in #1
foreach \stangle[
expand list,
count=\inlineiconcounter,
evaluate={\stAngle=\stangle+sign(\n{delta})*(abs(\n{delta})==
\pgfkeysvalueof{/tikz/arcs around/test}?2:0);}
] in {\pgfkeysvalueof{/tikz/arcs around/a}}{
([shift=(\stAngle:\n{radius})]\tikzlastnode.center)
edge[arcs around/arc={\inlineiconcounter}{\stAngle}{\n{delta}}]()
}
}
},
poly shape/.style={
shape=regular polygon, regular polygon sides={#1}, at={(0,0)},
fill={rgb:red,0;green,149;blue,182}, minimum size=+1cm, draw=none},
trans matrix/.style={
matrix of nodes,
nodes in empty cells,
row sep=.2em,
column sep=.4em,
% counteract any cells={nodes={<styles>}}
arcs around/node/.append style={draw=none, fill=none, minimum size=+1pt}
},
>={Stealth[scale=.8,round,bend]},
]
\matrix (m4) [
trans matrix,
arcs around/a={0,180},
cells={nodes={poly shape=4}}]{
& |[arcs around node={d= 90}]|
& |[arcs around node={d=180}]|
& |[arcs around node={d=-90, swap}]| \\
|[arcs around node={d= 90}]|
& |[arcs around node={d=180}]|
& |[arcs around node={d=-90, swap}]|
& \\
};
\matrix at (m4.south west) [
trans matrix,
anchor=north west,
yshift=-1.2em,
% triangle setup:
cells={nodes={poly shape=3}},
arcs around={
test=120,
a={0,120,240}
}
]{
& |[arcs around node={d=120}]|
& |[arcs around node={a={0,240,120}, d=240,
arc/.append style={
shift={(##2:##1*2pt)},
radius/.expanded=\pgfkeysvalueof{/tikz/x radius}+##1*2pt
}}]|
& |[arcs around node={d=-120, swap}]| \\
};
\end{tikzpicture}
\end{document}
Output
