
答案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}