我想在电路线上添加方波。如何才能高效地做到这一点?
提前致谢!
答案1
这听起来像是语法的完美用法pic
:
\documentclass[tikz, border=5pt]{standalone}
\begin{document}
\tikzset{
square wave/.pic={\draw[scale=.1] (-#1,-.5)
\foreach \i in {1,...,#1}{-| ++(1,1) -| ++(1,-1)};},
pics/square wave/.default=2,
}
\begin{tikzpicture}
\draw (0,0) -- pic[sloped, above=3mm] {square wave} (1,1);
\draw (0,0) to [bend right]
pic[sloped, scale=.5, pos=.7, blue, below=3mm] {square wave=3} (2,0);
\end{tikzpicture}
\end{document}