TikZ 中的不对称云形状

TikZ 中的不对称云形状

我有这个小云形状,我想在我的系统图表中使用它。

\usetikzlibrary{shapes}

\begin{tikzpicture}
\node [cloud, draw,cloud puffs=10,cloud puff arc=120, aspect=2, inner ysep=1em] {};
\end{tikzpicture}

它看起来像这样:

对称云

但问题是云太对称了。我希望其中一侧“更短”。类似这样(当然,减去箭头、文本和阴影):

不对称云

在手册或网上都找不到任何内容。有什么提示吗?

答案1

这不是一个很好的答案,但是我没有足够的时间来做一个新形状,你可以从这个答案中找到很多例子来做一个新形状(蝙蝠侠或其他形状)。

我手动制作了一朵云,并在里面放置了文字。您可以制作一个宏来同时绘制云和放置文字。

您可以使用节点(cloud)放置箭头等。

你可以做什么:

  • 新形状:不对称云
  • 或者使用宏来绘制云并放置文本

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\newcommand{\asymcloud}[2][.1]{%
\begin{scope}[#2]
\pgftransformscale{#1}%    
\pgfpathmoveto{\pgfpoint{261 pt}{115 pt}} 
  \pgfpathcurveto{\pgfqpoint{70 pt}{107 pt}}
                 {\pgfqpoint{137 pt}{291 pt}}
                 {\pgfqpoint{260 pt}{273 pt}} 
  \pgfpathcurveto{\pgfqpoint{78 pt}{382 pt}}
                 {\pgfqpoint{381 pt}{445 pt}}
                 {\pgfqpoint{412 pt}{410 pt}}
  \pgfpathcurveto{\pgfqpoint{577 pt}{587 pt}}
                 {\pgfqpoint{698 pt}{488 pt}}
                 {\pgfqpoint{685 pt}{366 pt}}
  \pgfpathcurveto{\pgfqpoint{840 pt}{192 pt}}
                 {\pgfqpoint{610 pt}{157 pt}}
                 {\pgfqpoint{610 pt}{157 pt}}
  \pgfpathcurveto{\pgfqpoint{531 pt}{39 pt}}
                 {\pgfqpoint{298 pt}{51 pt}}
                 {\pgfqpoint{261 pt}{115 pt}}
\pgfusepath{fill,stroke}         
\end{scope}}    
\begin{document}
 \begin{tikzpicture}
 \draw (0,0) rectangle (15,10) ;
 \node (cloud) at (8,7) {\tikz \asymcloud{fill=gray!20,thick};};
 \node at (4,6) {\tikz[cm={-1,0,0,1,(0,0)}]\asymcloud[.15]{fill=gray!20,thick};}; 
 \node at (8,7) {Net};
\end{tikzpicture}

\end{document}  

在此处输入图片描述

答案2

我在一次大学讲座中需要在一幅图形中使用云形,我想出了这个解决方案:

非对称云

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[magyar]{babel}

\usepackage{tikz}
\usetikzlibrary{positioning, shapes}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}


\begin{document}

\begin{tikzpicture}[font=\large\sffamily]

\node[cloud, cloud puffs=15.7, cloud ignores aspect, minimum width=5cm, minimum height=2cm, align=center, draw] (cloud) at (0cm, 0cm) {Cloud};

\end{tikzpicture}

\end{document}

关键是使用cloud ignores aspect关键字,并使用minimum widthminimum height关键字控制宽度和高度。为指定一个浮点数可以实现不对称cloud puffs

虽然不完美,但这是我现在所用的。

答案3

显然,不对称云甚至可以简单地绘制。您想要的云的精确副本是:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw (-1.6,-0.7) .. controls (-2.3,-1.1)
and (-2.7,0.3) .. (-1.7,0.3) .. controls (-1.6,0.7)
and (-1.2,0.9) .. (-0.8,0.7) .. controls (-0.5,1.5)
and (0.6,1.3) .. (0.7,0.5) .. controls (1.5,0.4)
and (1.2,-1) .. (0.4,-0.6) .. controls (0.2,-1)
and (-0.2,-1) .. (-0.5,-0.7) .. controls (-0.9,-1)
and (-1.3,-1) .. cycle;

\end{tikzpicture}   
\end{document}

在此处输入图片描述

编辑。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\AsymCloud}[3]{
\begin{scope}[shift={#1},scale=#3]
\draw (-1.6,-0.7) .. controls (-2.3,-1.1)
and (-2.7,0.3) .. (-1.7,0.3)coordinate(asy1) .. controls (-1.6,0.7)
and (-1.2,0.9) .. (-0.8,0.7) .. controls (-0.5,1.5)
and (0.6,1.3) .. (0.7,0.5) .. controls (1.5,0.4)
and (1.2,-1) .. (0.4,-0.6)coordinate(asy2) .. controls (0.2,-1)
and (-0.2,-1) .. (-0.5,-0.7) .. controls (-0.9,-1)
and (-1.3,-1) .. cycle;
\node at ($(asy1)!0.5!(asy2)$) {#2};
\end{scope}
}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
%\AsymCloud{coordinate}{text}{scale factor}
\AsymCloud{(0,0)}{text}{1}
\AsymCloud{(0,-6)}{very very very very very very long text}{2}
\end{tikzpicture} 
\end{document}

在此处输入图片描述

相关内容