\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}
\draw plot [hobby] coordinates {(0,4) (1,3.2) (2,1.5) (2.5,1.2) (3,1) (4,0.8)};
\end{tikzpicture}
\begin{tikzpicture}
\draw[black, thick] (-1,1) -- (1,-1);
\draw[black, thick] (-1,-1) -- (1,1);
\filldraw[black] (0,0) circle (2pt) ;
\draw[black, thick] (0,0) -- (0,-1.5);
\draw[black, thick] (0,-1.5) -- (0.5,-1);
\draw[black, thick] (0,-1.5) -- (-0.5,-2);
\filldraw[color=red!60, fill=red!5, very thick](-1,1) circle (.3);
\filldraw[color=red!60, fill=white, very thick](-1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,1) circle (.3);
\draw (-.5,-2) .. controls (0.1,-2.8) and (.3,-2) .. (.5,-1);
\end{tikzpicture}
\end{document}
我已经这样做了,但不知道如何将其付诸实践。
答案1
我建议使用pic
,它就像一个tikzpicture
可以在路径上使用的迷你。在下面的代码中,我将您的无人机代码变成了pic
。代码的原点决定了 的pic
放置位置,因此我使用 移动了位置yshift
(并对其进行了缩放)。然后,您可以像放置任何节点一样将其放置在路径上。
为了好玩我使用 制作了一条随机河流decorations.pathmorphing
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, decorations.pathmorphing}
\tikzset{drone/.pic={
\draw[black, thick] (-1,1) -- (1,-1);
\draw[black, thick] (-1,-1) -- (1,1);
\filldraw[black] (0,0) circle (2pt) ;
\draw[black, thick] (0,0) -- (0,-1.5);
\draw[black, thick] (0,-1.5) -- (0.5,-1);
\draw[black, thick] (0,-1.5) -- (-0.5,-2);
\filldraw[color=red!60, fill=red!5, very thick](-1,1) circle (.3);
\filldraw[color=red!60, fill=white, very thick](-1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,-1) circle (.3);
\filldraw[color=red!60, fill=red!5, very thick](1,1) circle (.3);
\draw (-.5,-2) .. controls (0.1,-2.8) and (.3,-2) .. (.5,-1);
}
}
\begin{document}
\begin{tikzpicture}[every pic/.style={yshift=1cm, scale=.5, transform shape}]
\pgfmathsetseed{1415}
\draw[decorate, decoration={random steps, segment length=3mm, amplitude=1pt}, line width=8mm, cyan!60!white](-.5,-.4)--(9,-.4);
\draw[<->, thick](0,1.5)node[left]{$z$}|-(1.5,0)node[below]{$x$};
\draw(0,4)to[out=-20, in=180]pic[pos=0]{drone}pic[pos=1]{drone}(5,0)pic[xshift=3cm]{drone};
\draw[<->, thick, red](0,-1)--node[below]{flying}(5,-1);
\draw[<->, thick, red](5,-1)--node[below]{sailing}(9,-1);
\end{tikzpicture}
\end{document}