TikZ 中的随机平滑椭圆

TikZ 中的随机平滑椭圆

我曾尝试在 TikZ 中用装饰画一个随机、平滑的椭圆,然后我想出了类似的东西,但端点不匹配:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
    \begin{tikzpicture}[decoration={random steps,segment length=12.5mm,amplitude=6mm}]
        \draw[decorate,rounded corners=4mm] (0,0) ellipse (1.3cm and 2cm);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

重复构造几次表明,差距是一个系统错误,不是来自随机性:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
    \begin{tikzpicture}[decoration={random steps,segment length=12.5mm,amplitude=6mm}]
        \foreach \i in {1,...,10} {\draw[decorate,rounded corners=4mm] (0,0) ellipse (1.3cm and 2cm);}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

有什么问题?我该如何解决?

答案1

您必须谨慎选择的segment length尺寸。amplituderounded corners

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
    \begin{tikzpicture}[decoration={random steps,segment length=3pt,amplitude=2pt}]
        \draw[decorate,rounded corners=1pt] (0,0) ellipse (1.3cm and 2cm);
    \end{tikzpicture}
    \begin{tikzpicture}[decoration={random steps,segment length=3pt,amplitude=1pt}]
        \draw[decorate,rounded corners=1pt] (5,0) ellipse (1.3cm and 2cm);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容