我正在寻找一种方法来绘制由多个云形状组成的图像。以下 MWE:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\newcommand{\CloudDist}{1.8}
\tikzstyle {cloudkeys} = [cloud puffs=30, cloud puff arc=150, aspect=1.25, inner sep=0.7cm,]
\tikzstyle {mycloud} = [draw, cloud, cloudkeys, fill=blue!25, nearly opaque]
\coordinate (cloud 0);
\coordinate [right=\CloudDist cm of cloud 0] (cloud 1);
\coordinate [right=\CloudDist cm of cloud 1] (cloud 2);
\foreach \x in {0,1,2} {
\node [mycloud] at (cloud \x) (local map cloud shape \x) {};
}
\end{tikzpicture}
\end{document}
产生这个数字:
但期望的结果如下:
我找到了一些答案几乎告诉我怎样做。
我认为可以通过混合使用这些答案来实现想要做的事情,但我自己做不到。如果有人能告诉我如何绘制这个图形,我将不胜感激。
答案1
您可以使用裁剪,但另一种解决方案更简单。请注意,节点锚点不形成矩形。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\newcommand{\CloudDist}{1.8}
\tikzstyle {cloudkeys} = [cloud puffs=30, cloud puff arc=150, aspect=1.25, inner sep=0.7cm,]
\tikzstyle {mycloud} = [draw, cloud, cloudkeys, fill=blue!25, nearly opaque]
\coordinate (cloud 0);
\coordinate [right=\CloudDist cm of cloud 0] (cloud 1);
\coordinate [right=\CloudDist cm of cloud 1] (cloud 2);
\path (cloud 0) -- (cloud 1) coordinate[midway] (cloud edge 1);
\path (cloud 1) -- (cloud 2) coordinate[midway] (cloud edge 2);
\begin{scope}
\node[cloud, cloudkeys,outer sep=2pt] (temp) at (cloud 0) {};% invisible, used for clip rectangle
\clip (temp.south -| temp.west) rectangle (temp.north -| cloud edge 1);
\node [mycloud] at (cloud 0) (local map cloud shape 0) {};
\end{scope}
\begin{scope}
\node[cloud, cloudkeys,outer sep=2pt] (temp) at (cloud 1) {};% invisible, used for clip rectangle
\clip (temp.south -| cloud edge 1) rectangle (temp.north -| cloud edge 2);
\node [mycloud] at (cloud 1) (local map cloud shape 1) {};
\end{scope}
\begin{scope}
\node[cloud, cloudkeys,outer sep=2pt] (temp) at (cloud 2) {};% invisible, used for clip rectangle
\clip (temp.south -| cloud edge 2) rectangle (temp.north -| temp.east);
\node [mycloud] at (cloud 2) (local map cloud shape 2) {};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
不需要剪辑。
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\newcommand{\CloudDist}{1.8}
\tikzstyle {cloudkeys} = [cloud puffs=30, cloud puff arc=150, aspect=1.25, inner sep=0.7cm,]
\tikzstyle {mycloud1} = [draw, cloud, cloudkeys, fill=blue!25]
\tikzstyle {mycloud2} = [ cloud, cloudkeys, fill=blue!25]
\coordinate (cloud 0);
\coordinate [right=\CloudDist cm of cloud 0] (cloud 1);
\coordinate [right=\CloudDist cm of cloud 1] (cloud 2);
\begin{scope}[transparency group,nearly opaque]
\foreach \x in {0,1,2} {
\node [mycloud1] at (cloud \x) (local map cloud shape \x) {};
}
\foreach \x in {0,1,2} {
\node [mycloud2] at (cloud \x) (local map cloud shape \x) {};
}
\end{scope}
\end{tikzpicture}
\end{document}