I've come again to pic your interesting brains.
I am trying to make a custom node with a drawing I've made
\documentclass[tikz, margin=3mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots,tikz}
\pgfplotsset{compat=1.16}
\usetikzlibrary{calc}
\tikzset{
pics/mynodeB/.style={
code={
\draw[fill] (0,0.5) circle (1cm);
\draw[line width=4pt] (0,0) circle (2.2cm) ;
\pgfmathsetmacro{\AngleA}{52.5}
\draw[fill] (0,-2) arc (-90:-37.8:2cm) arc (29:66.2:1.8cm) arc (-\AngleA:{-180+\AngleA}:1.2cm) arc ({180-66.2}:{180-29}:1.8cm) arc ({-180+37.8}:-90:2cm) ;
}
},
cross/.style={path picture={
\draw[black] let
\p1 = (path picture bounding box.south),
\p2 = (path picture bounding box.north),
\n1 = {veclen((\x2-\x1),(\y2-\y1))}
in ($(path picture bounding box.south east)!0.5!(path picture bounding box.north west)$) circle (1cm); % Change is to be made here
}},
}
\begin{document}
\begin{tikzpicture}
\draw[fill] (0,0.5) circle (1cm);
\draw[line width=4pt] (0,0) circle (2.2cm) ;
\pgfmathsetmacro{\AngleA}{52.5}
\draw[fill] (0,-2) arc (-90:-37.8:2cm) arc (29:66.2:1.8cm) arc (-\AngleA:{-180+\AngleA}:1.2cm) arc ({180-66.2}:{180-29}:1.8cm) arc ({-180+37.8}:-90:2cm) ;
\pic[red] at (5,0) {mynodeB};
\node[cross,minimum size=2cm] at (10,0) {};
\end{tikzpicture}
\end{document}
It gives this
The first is the drawing I'm trying to use. You can see some weird numerical values because I had drawn it using filled circles and some clipping/reversed clipping but it was not working well when I tried to turn it into a node so I approximated the shape with arcs.
The red one is the same drawing done with a "pic" I defined (I don't really know what a pic is, I used a code I found here...). The problem is that a pic is not a node, and I can't use my usual commands to play with it.
The circle on the right is based on a simpler custom node I had made previously. I am trying to make the same drawing than before, but I must not use fixed length (or the shape won't be resized with the node). You can see I have tried in cross/.style
evaluating the length \n1
of the node, but if I put \n1
where 1cm
is, the circle disappears.
Do you have ideas ?