我正在嘗試創建一個如圖所示的光柵圖案。我相信重複的形狀可以使用for迴圈在 tikz 中,但我無法正確完成它。
感謝任何幫助循環。
編輯:這是更大圖表的一部分,以下是程式碼。
\begin{document}
\begin{tikzpicture}[>={Stealth[inset=0pt,length=10pt,angle'=35,round]}]
\pgfmathsetmacro{\lensRadius}{6}
\pgfmathsetmacro{\lensHeight}{3}
\pgfmathsetmacro{\startAngle}{asin(\lensHeight/\lensRadius)}
\draw [] (0,\lensHeight)
arc[start angle=180-\startAngle,delta
angle=2*\startAngle,radius=\lensRadius]node [below, align=center] {\\
[1em]Main\\[-1ex]lens}
arc[start angle=-\startAngle,delta angle=2*\startAngle,radius=\lensRadius]
-- cycle;
\draw [line width=1mm ] (-1.5,3) -- (-1.5,-3) node [below, align=center] {\\
[1em]Weak\\[-1ex]diffuser};
\draw [] (6,\lensHeight)
arc[start angle=180-\startAngle,delta
angle=2*\startAngle,radius=\lensRadius]node [below, align=center] {\\
[1em]Field\\[-1ex]lens}
-- cycle;
\draw[] plot[only marks, mark=*,mark size=10pt,mark options={fill=Sepia}]
coordinates{(-6.5,0)} node[below, align=center]{\\[1em]Object};
\draw[] (-6,0) -- (0,3);
\draw[] (-6,0) -- (0,-3);
\draw[] (6.5,0) -- (0,3);
\draw[] (6.5,0) -- (0,-3);
%lenticular pattern
\pgfmathsetmacro{\lensRadius}{0.2}
\pgfmathsetmacro{\lensHeight}{0.2}
\pgfmathsetmacro{\startAngle}{asin(\lensHeight/\lensRadius)}
\draw [] (8,\lensHeight)
arc[start angle=180-\startAngle,delta
angle=2*\startAngle,radius=\lensRadius];
\draw [line width=0.25mm ] (8,3) -- (8,-3) -- (8.2,-3) -- (8.2,3) -- cycle;
\end{tikzpicture}
\end{document}
輸出:
答案1
繪製類似的東西有很多種可能性,這是其中之一。
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[pics/rr/.style={code={\draw (0.2,-0.2) |- ++(-0.4,0.4)
to[out=180,in=180] ++ (0,-0.4) -- cycle;}}]
\path foreach \X in {0,1,...,10}
{(0,0.4*\X) pic{rr}};
\draw (0.2,-0.2) rectangle (0.4,10*0.4+0.2);
\end{tikzpicture}
\end{document}