显然,制作这样的作品的最佳方式
是 TikZ 中的 Lindenmayer 系统。
以下是我的一些尝试,根据评论中的建议进行保留。
\documentclass[tikz]{standalone}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\pgfdeclarelindenmayersystem{try}{
\symbol{S}{\pgflsystemstep=.6\pgflsystemstep}
\rule{X -> FS[S-Y]YF}
\rule{Y -> FS[SX-]XF}
}
\begin{tikzpicture}
\draw [rotate=45]
[l-system={try, axiom=X, order=10, step=124pt, angle=90}]
lindenmayer system;
\end{tikzpicture}
\end{document}
\documentclass[tikz]{standalone}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\pgfdeclarelindenmayersystem{try}{
\symbol{S}{\pgflsystemstep=.8\pgflsystemstep}
\rule{X -> FX[-SFY]FX}
\rule{Y -> FY[+FX]FY}
}
\begin{tikzpicture}
\draw [rotate=-45]
[l-system={try, axiom=X, order=7, step=1.2pt, angle=90}]
lindenmayer system;
\end{tikzpicture}
\end{document}
\documentclass[tikz]{standalone}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\pgfdeclarelindenmayersystem{try}{
\symbol{S}{\pgflsystemstep=.67\pgflsystemstep}
\symbol{p}{\draw circle (.01\pgflsystemstep);}
\rule{X -> FS[+S[p]Y]X}
\rule{Y -> FS[S[p]X]Y}
}
\begin{tikzpicture}
\draw [rotate=135]
[l-system={try, axiom=X, order=12, step=140pt, angle=90}]
lindenmayer system;
\end{tikzpicture}
\end{document}
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\pgfdeclarelindenmayersystem{try}{
\symbol{S}{\pgflsystemstep=.67\pgflsystemstep}
\symbol{p}{\draw circle (.01\pgflsystemstep);}
\rule{X -> [p]FS[-ff++SY]X}
\rule{Y -> [p]FS[+ff--SX]Y}
}
\begin{tikzpicture}
\draw [rotate=45]
[l-system={try, axiom=X, order=12, step=160pt, angle=90}]
lindenmayer system;
\end{tikzpicture}
\end{document}
答案1
这还不是一个完整的答案,但由于 OP 的输入,我们可能已经接近目标。这个答案的作用是定义一个减小幅度的锯齿形的规则,以及将它们组合起来的方法。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{lindenmayersystems}
\def\pgflsystemturnr{%
\pgftransformrotate{-90}}%
\def\pgflsystemturnl{%
\pgftransformrotate{90}}%
\begin{document}
\begin{tikzpicture}[l-system={step=10pt, order=7,angle=165}]
\pgfdeclarelindenmayersystem{pft}{
\symbol{D}{\pgflsystemdrawforward}
\symbol{M}{\pgflsystemmoveforward}
\symbol{S}{\pgflsystemstep=0.9\pgflsystemstep}
\symbol{I}{\pgflsystemstep=1.1\pgflsystemstep}
\symbol{L}{\pgflsystemstep=3\pgflsystemstep}
\symbol{l}{\pgflsystemturnl}
\symbol{r}{\pgflsystemturnr}
\rule{Z -> [Y]-DDDDDSS+Z} % line up zigzag
\rule{Y -> -DI+DI-DI+DI-DI+DI-DI+DI-DI+DI-DI+DI-DI+DI-DI+DI} % zigzag
}
\draw [red,rotate=-60] (0,0) l-system [l-system={pft, axiom=Z, anchor=south west}];
\end{tikzpicture}
\end{document}
使用这个可以获得类似于您的屏幕截图的东西。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{lindenmayersystems}
\def\pgflsystemturnr{%
\pgftransformrotate{-90}}%
\def\pgflsystemturnl{%
\pgftransformrotate{90}}%
\newcounter{lmn}
\begin{document}
\begin{tikzpicture}[l-system={step=10pt, order=8,angle=165},line join=bevel,
pics/linden row/.style={code={\draw[shorten >=-#1*0.05cm] (0,0) -- (-142.5:2*#1)
foreach \XX in {1,...,#1} {coordinate[pos={pow(0.75,\XX-1)}] (p-#1-\XX)
node[circle,fill,pos={1.02*pow(0.75,\XX-1)},scale={pow(0.75,\XX-1)}]{}};
\foreach \XX in {1,...,#1}
{\draw[rotate=-57.5] (p-#1-\XX)
l-system [l-system={pft,step={pow(0.8,-#1+2*\XX+5)*4pt}, axiom=Z, anchor=west}];}}}]
\pgfdeclarelindenmayersystem{pft}{
\symbol{D}{\pgflsystemdrawforward}
\symbol{M}{\pgflsystemmoveforward}
\symbol{S}{\pgflsystemstep=0.9\pgflsystemstep}
\symbol{I}{\pgflsystemstep=1.1\pgflsystemstep}
\symbol{L}{\pgflsystemstep=3\pgflsystemstep}
\symbol{l}{\pgflsystemturnl}
\symbol{r}{\pgflsystemturnr}
\symbol{o}{\stepcounter{lmn}%
\pgfnode{coordinate}{center}{\pgfpointorigin}{X\number\value{lmn}}{}}%
\symbol{c}{\pgfpathlineto{\pgfpointanchor{X\number\value{lmn}}{center}}}
\rule{Z -> [Y]-DDDDDSS+Z} % line up zigzag
\rule{Y -> rMl-Do[rD]I+DI-DI+DI-DI+DI-DI+DI-DI+DI-DI+DI-DI+DI-DI[c]+DI} % zigzag
}
\path foreach \X in {4,5,...,8} {(-30:{pow(1.2,\X)*6cm}) pic{linden row=\X}};
\end{tikzpicture}
\end{document}
答案2
下面是一个相当接近它的代码。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\pgfdeclarelindenmayersystem{try}{
\symbol{S}{\pgflsystemstep=.67\pgflsystemstep}
\symbol{p}{\draw circle (.01\pgflsystemstep);}
\rule{X -> [p]S[-FF++SY]Xf}
\rule{Y -> [p]S[+FF--SX]Yf}
}
\begin{tikzpicture}
\draw [rotate=45]
[l-system={try, axiom=X, order=12, step=280pt, angle=90}]
lindenmayer system;
\end{tikzpicture}
\end{document}
是否可以做得更好,我不知道,欢迎大家进一步改进