答案1
一个简单的方法是使用path picture
。使用一些额外的魔法,可以设置路径图片,因此(-1,-1)
是图片的左下角,(1,1)
是图片的右上角。这使得指定路径图片元素变得非常简单。
\documentclass[tikz,border=5]{standalone}
\tikzset{%
do path picture/.style={%
path picture={%
\pgfpointdiff{\pgfpointanchor{path picture bounding box}{south west}}%
{\pgfpointanchor{path picture bounding box}{north east}}%
\pgfgetlastxy\x\y%
\tikzset{x=\x/2,y=\y/2}%
#1
}
},
sin wave/.style={do path picture={
\draw [line cap=round] (-3/4,0)
sin (-3/8,1/2) cos (0,0) sin (3/8,-1/2) cos (3/4,0);
}},
cross/.style={do path picture={
\draw [line cap=round] (-1,-1) -- (1,1) (-1,1) -- (1,-1);
}},
plus/.style={do path picture={
\draw [line cap=round] (-3/4,0) -- (3/4,0) (0,-3/4) -- (0,3/4);
}}
}
\begin{document}
\begin{tikzpicture}[minimum size=0.75cm]
\node [circle, draw, sin wave] at (-1, 0) {};
\node [circle, draw, plus] at ( 0, 0) {};
\node [circle, draw, cross] at ( 1, 0) {};
\end{tikzpicture}
\end{document}