我想要(出于演示目的)一条线从一个特定点开始(假设(0, 0)
出口角为 )90°
,经过一些循环(最好是随机的),然后(2, 0)
以输入角 为返回90°
。不幸的是,我没有找到任何解决方案。创建这样一条线的最佳方法是什么?
答案1
您需要的是库random steps
中的装饰。这是一个示例。decorations.pathmorphing
tikz
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\draw [olive,thick, decorate, decoration={random steps,segment length=5pt,amplitude=3pt}]
(0,0) to[out=90,in=90] (2,0);
\end{tikzpicture}
\end{document}
segment length=5pt,amplitude=3pt
按照您的意愿更改值。
以下是一个变体:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\draw [olive,thick, decorate, decoration={random steps,segment length=3pt,amplitude=1pt}]
(0,0) -- (0,2mm) to[out=90,in=90,distance=3cm] (2,2mm) -- (2,0);
\end{tikzpicture}
\end{document}
可以使它们相互交叉。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\draw [olive,thick, decorate, decoration={random steps,segment length=3pt,amplitude=1pt}]
(0,0)circle (1.5);
\draw [olive,thick, decorate, decoration={random steps,segment length=3pt,amplitude=1pt}]
(2,0) to[out=40,in=135,distance=3cm] (3,0) to[out=225,in=40,distance=3cm] (2,-2);
\draw [olive,thick, decorate, decoration={random steps,segment length=3pt,amplitude=1pt}]
(4,0) to[out=40,in=135,distance=3cm] (5,0) to[out=40,in=135,distance=3cm] (6,0);
\end{tikzpicture}
\end{document}