被环包围的 Spring 网络

被环包围的 Spring 网络

感谢@marmot,我在 TikZ 中绘制了一个方形弹簧格子。请参阅附加的代码。但是,我想用彩色背景(比如说浅灰色)的多边形包围该格子,网络不再延伸到该格子之外。照片中给出了一个类似的例子。提前感谢您的帮助。

\documentclass[14pt,a4]{article}
\usepackage{tikz}
\usetikzlibrary{svg.path}
\usepackage{fourier-orns}
\usepackage{multido}
\usepackage[mathscr]{euscript}

\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
\clip (-1,-1) rectangle (11,11);
\foreach \X in {-2,0,...,10}
{\foreach \Y in {-2,0,...,10}
{\draw[decorate,decoration={coil,aspect=0.5,amplitude=1.5mm, segment length=1.5mm}] (\X,\Y) -- ++(0,2) -- ++(2,0);
\node[circle,inner color=black,outer color=white] at (\X,\Y) {$\bullet$};}}
\end{tikzpicture}
\end{document}

答案1

像这样吗?

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
\draw[gray,decorate,decoration={coil,aspect=0,segment length=4.5mm}] 
plot[smooth cycle,tension=0.3] coordinates {(-0.75,-0.75) (10.75,-0.75)
 (10.75,10.75) (-0.75,10.75)};
\clip decorate [decoration={coil,aspect=0,segment length=4.5mm}] 
{plot[smooth cycle,tension=0.3] coordinates {(-0.75,-0.75) (10.75,-0.75)
 (10.75,10.75) (-0.75,10.75)}};
\foreach \X in {-2,0,...,10}
{\foreach \Y in {-2,0,...,10}
{\draw[decorate,decoration={coil,aspect=0.5,amplitude=1.5mm, segment length=1.5mm}] (\X,\Y) -- ++(0,2) -- ++(2,0);
\node[circle,inner color=black,outer color=white] at (\X,\Y) {$\bullet$};}}
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者没有摆动。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
\draw[gray] 
plot[smooth cycle,tension=0.3] coordinates {(-0.75,-0.75) (10.75,-0.75)
 (10.75,10.75) (-0.75,10.75)};
\clip plot[smooth cycle,tension=0.3] coordinates {(-0.75,-0.75) (10.75,-0.75)
 (10.75,10.75) (-0.75,10.75)};
\foreach \X in {-2,0,...,10}
{\foreach \Y in {-2,0,...,10}
{\draw[decorate,decoration={coil,aspect=0.5,amplitude=1.5mm, segment length=1.5mm}] (\X,\Y) -- ++(0,2) -- ++(2,0);
\node[circle,inner color=black,outer color=white] at (\X,\Y) {$\bullet$};}}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容