在域边界上用不同的颜色绘制任意域

在域边界上用不同的颜色绘制任意域

我想在 tikz 中绘制一个任意域,并在边界上使用不同的颜色。我已经成功绘制了一个任意域,但无法正确为边界着色。

这是我想要的样子的图片(形状不必精确),特别是域中边界的颜色

在此处输入图片描述

以下是我所拥有的 MWE

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture} [line width=1.2, scale=2 ]

\def\x{1} ;
\def \y{4};


%%%% Domain in reference configuration
\draw plot [smooth cycle] coordinates {(1.0,.1)(1.75,0.05)(2.5,.5)(2.9,1.5)(2.8,2.8)(2.0, 2.9)(1.0,2.6)(0.3, 1.3)(0.5,0.5)} node at (2.6,2.6)[ scale=1] {$\mathcal{B}$};


\draw [blue, line width=2mm, opacity=0.5] plot [smooth ] coordinates {(2.9,1.5)(2.8,2.8)(2.0, 2.9)(1.0,2.6)};

\draw[red, line width=2mm, opacity=0.5] plot [smooth ] coordinates {(1.75,0.05)(2.5,.5)(2.9,1.5)};

\draw [blue, line width=2mm, opacity=0.5]plot [smooth] coordinates {(0.5,0.5)(1.0,.1)(1.75,0.05)};

\draw [red, line width=2mm, opacity=0.5]plot [smooth] coordinates {(1.0,2.6)(0.3, 1.3)(0.5,0.5)};
\end{tikzpicture}
\end{figure}


\end{document}

编译后如下所示:

在此处输入图片描述

边界的颜色看起来不平滑。事实上,我发现它完全不雅致。

有没有办法让它看起来像第一张图片中的那样?

答案1

带夹子。(概念上与这个答案

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture} [line width=1.2, scale=2 ]
%%%% Domain in reference configuration
\draw plot [smooth cycle] coordinates {(1.0,.1)(1.75,0.05)(2.5,.5)(2.9,1.5)(2.8,2.8)(2.0, 2.9)(1.0,2.6)(0.3, 1.3)(0.5,0.5)} node at (2.6,2.6)[ scale=1] {$\mathcal{B}$};
\begin{scope}
\clip plot [smooth cycle] coordinates {(2.9,1.5)(1.0,2.6)(0.3, 1.3)(2.5,.5)};
\draw[blue, line width=2mm, opacity=0.5] plot [smooth cycle] coordinates {(1.0,.1)(1.75,0.05)(2.5,.5)(2.9,1.5)(2.8,2.8)(2.0, 2.9)(1.0,2.6)(0.3, 1.3)(0.5,0.5)};
\end{scope}
\begin{scope}
\clip plot [smooth cycle] coordinates {(2.9,1.5)(1.0,2.6)(0.3, 1.3)(2.5,.5)}
(current bounding box.south west) rectangle (current bounding box.north east);
\draw[red, line width=2mm, opacity=0.5] plot [smooth cycle] coordinates {(1.0,.1)(1.75,0.05)(2.5,.5)(2.9,1.5)(2.8,2.8)(2.0, 2.9)(1.0,2.6)(0.3, 1.3)(0.5,0.5)};
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

相关内容