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:

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

2 Answers 2

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

5
  • Is it possible to scale cloud smaller?
    – alper
    Jul 9, 2022 at 13:10
  • Also idk but Cloud Storage is written having new line in between when I try your code
    – alper
    Jul 9, 2022 at 13:12
  • I mistakenly left \baselineskip=18pt for testing - now changed back to 8pt. The scaling of the cloud is controlled by the third parameter - try \AsymCloud{(0.3,0.8)}{}{0.7} Jul 9, 2022 at 14:45
  • sorry I forget to ask in my question, is it possible to make line of the cloud little bit thicker?
    – alper
    Jul 9, 2022 at 21:13
  • 1
    You can add the option thick, very thick, ultra thick or line width=5pt. Jul 9, 2022 at 21:20
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

3
  • Thanks for the all combinations. Is it possible to make cloud's left side pop-up half circle little bit more wider?
    – alper
    Jul 9, 2022 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. Jul 9, 2022 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 9, 2022 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .