3

I am trying to draw a cloud figure in the background of a cylinder. Original example, sorry I was not able to find the cylinder version of it:

enter image description here

Latex version of the wanted figure:

enter image description here


What I have as follows, cloud is taken from the following answer for Asymmetric cloud shape in TikZ:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\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{(0,1)}{}{1} at (0,1)
    %\AsymCloud{coordinate}{text}{scale factor}
    \node[text width=1cm,text centered] (A) [cylinder, shape border rotate=90, draw,minimum height=0.5cm,minimum
width=0.5cm, shape
        aspect=0.4,execute at begin node=\setlength{\baselineskip}{8pt}]{\scriptsize{Cloud Storage}};
\end{tikzpicture}
\end{document}

I was not able to aligh cloud to correct place and draw it in the background. If possible I want to define cloud as a node.

its output:

enter image description here

Related:

alper
  • 1,389
  • Where does execute at begin node=... come from? -For me that seems like a very extreme way to do a simple thing. – hpekristiansen Jul 09 '22 at 12:21
  • Ah original figure is coming from https://tex.stackexchange.com/a/646749/127048 ; where I had to connect the cylinder using arrows – alper Jul 09 '22 at 13:01

2 Answers2

3
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{shapes}
\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;
\path (asy1) -- (asy2) node[pos=0.5] {#2};
\end{scope}
}
\begin{document}
\begin{tikzpicture}
\AsymCloud{(0.3,0.8)}{}{0.8}
\node[text width=1cm, text centered, cylinder, shape border rotate=90, draw, minimum height=0.5cm, minimum
width=0.5cm, shape aspect=0.4, font={\scriptsize\baselineskip=8pt}, fill=white, preaction={draw, white, line width=15pt}]{Cloud Storage};
\end{tikzpicture}
\end{document}

A cloud with a cylinder and text

3

A bit more parameterization.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds, calc, shapes}

% \AsymCloud{<name of a cylinder node>} \newcommand{\AsymCloud}[1]{ % helper rectangle to show the real bounding box of cylinder % \draw[red] (#1.bottom -| #1.after bottom) rectangle % (#1.top -| #1.after top); \draw[shorten <=3pt, shorten >=3pt] let \p1=(#1.bottom -| #1.after bottom), % real south east == (\x1, \y1) \p2=(#1.top -| #1.after top), % real north west == (\x2, \y2) \p3=($ (\p2) - (\p1) $) % total size == (\x3, \y3) in (\x2, \y1+.5\y3) % real west arc[start angle=-80, delta angle=150, radius=.3\y3] arc[start angle=0, delta angle=150, radius=.5\x3] arc[start angle=60, delta angle=150, radius=.1\x3+.1\y3] arc[start angle=120, delta angle=150, radius=.2\y3+.1*\x3] ; } \begin{document} \pagestyle{empty} \begin{tikzpicture}[every cylinder node/.style={ draw, text centered, text width=1cm, node font=\setlength{\baselineskip}{8pt}\scriptsize, shape aspect=0.4 }] \node[shape border rotate=90, minimum height=0.5cm, cylinder] (A) {Cloud Storage}; \AsymCloud{A}

\node[shape border rotate=90, minimum height=2.5cm, cylinder]
  at (3,0) (B) {Cloud Storage};
\AsymCloud{B}

\node[shape border rotate=90, minimum width=2.5cm, cylinder]
  at (7,0) (C) {Cloud Storage};
\AsymCloud{C}

\node[shape border rotate=90, minimum size=2.5cm, cylinder]
  at (11,0) (D) {Cloud Storage};
\AsymCloud{D}

\end{tikzpicture} \end{document}

enter image description here

muzimuzhi Z
  • 26,474
  • Thanks for the all combinations. Is it possible to make cloud's left side pop-up half circle little bit more wider? – alper Jul 09 '22 at 13:19
  • @alper Can't say it's impossible, but currently I don't have the time to really solve such a system of linear equations. Current parameters are just guessing with some luck. – muzimuzhi Z Jul 09 '22 at 13:46
  • Like on the second image it is in the same size as the top half circle but when the cloud get larger like the one on the rightest cloud, left cloud remains same size which seems much smaller – alper Jul 09 '22 at 13:54