图 TIKZ 的轨迹访问区域

图 TIKZ 的轨迹访问区域

我想用 tikz 创建带有绿色背景的下图。

数字

这是我目前所做的(带圆圈)

\begin{tikzpicture}
\draw (-4,-1) rectangle (4,4); % E
\draw (0,0) ++(45:2) circle (0.5); % B
\fill[color=green!30] \E;
\fill[opacity=0.5,red] \A;
\fill[opacity=0.5,red] \B;
\fill[opacity=0.5,red] \C;
\end{tikzpicture}

\newcommand{\E}{(-4,-1) rectangle (4,4)}
\newcommand{\A}{(0,0) ++(135:3) circle (0.7)}
\newcommand{\B}{(0,0) ++(45:1) circle (0.7)}
\newcommand{\C}{(0,0) ++(50:3.5) circle (1)}

您有什么想法吗?提前致谢

答案1

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{hobby, decorations.markings}
\tikzset{
->-/.style={decoration={markings, mark=at position #1 with {\arrow{>}}},postaction={decorate}},
dot/.pic={\fill (0,0) circle[radius=4pt];},
}
\begin{document}
\begin{tikzpicture}[use Hobby shortcut]
\draw[blue!50!black, fill=green!30, ultra thick] (0,0) rectangle (8,5);
\draw[blue!50!black, fill=red!50, thick, closed, shift={(2,3.5)}, scale=0.6] (1.5,0) foreach \n in {1,...,5} {.. ([shift=(\n*360/6:1.5)]rnd,rnd)};
\draw[blue!50!black, fill=red!50, thick, closed, shift={(6,3)},   scale=0.6] (1.5,0) foreach \n in {1,...,5} {.. ([shift=(\n*360/6:1.5)]rnd,rnd)};
\draw[blue!50!black, fill=red!50, thick, closed, shift={(4,1.5)}, scale=0.6] (1.5,0) foreach \n in {1,...,5} {.. ([shift=(\n*360/6:1.5)]rnd,rnd)};
\draw[blue!50!black, tension=0.5, ->-=0.55, ultra thick] (1,1)pic{dot} .. (2,3.5) .. (4,3) .. (6,3) .. (4,1.5) .. (3,1) .. (5,0.5) .. (7,1)pic{dot};
\end{tikzpicture}
\end{document}

包含三个红色形状和一条路径的绿色矩形

相关内容