2

I want to draw a cylinder from the node client to server1 passing through the cloud node and the firewall node. I used this example (page 774) as inspiration, but doesn't look good. Here is my MWE:

\documentclass{article}
\usepackage{xcolor}
    \definecolor{mycolor}{RGB}{8,108,131}
\usepackage{tikz} 
    \usetikzlibrary{chains}
    \usetikzlibrary{positioning}
    \usetikzlibrary{backgrounds}
    \usetikzlibrary{arrows,automata}
    \usetikzlibrary{shapes}
\begin{document}
  \begin{tikzpicture}[
                scale=0.8,
                transform shape,
                show background rectangle,
                %background rectangle/.style={fill=gray!10},
                box/.style={draw, font=\itshape}
                  ]
                \coordinate (b) at (current page.center);
                \node [
                    label=right:xx, 
                ] (firewall)at(b) {example-image-a};
                \node [
                    label=above:Client
                ] (client) at ([yshift=2cm]firewall){example-image-a};
                \node [
                    label=below:xx
                ] (dnsServer)  at([xshift=-5cm]firewall){example-image-a};
               \node [
                    label=center:Internet,
                ] (cloud) at ([yshift=-2cm]firewall){example-image-a};
                \node [
                    label=below:xx
                ] (server1) at([yshift=-2cm,xshift=-1cm]cloud){example-image-a};
                \node [
                    label=right:example.com
                ] (server2) at([yshift=-2cm,xshift=1cm]cloud){example-image-a};
               \draw [thick,mycolor,->](client) .. controls  (firewall) .. (dnsServer)node[very near start, left]{1};
                \draw [thick,mycolor,->](dnsServer) .. controls (firewall)and (cloud) .. (server1)node[very near end, left]{2};
                \draw [thick,mycolor,->](server1) .. controls  (cloud) and (firewall)..  (client)node[very near start, right]{5};
                \path[mycolor,->] (client) edge  [loop right] node {6} ();
                \node (A) [cylinder, shape border rotate=90,minimum height=1cm,minimum width=1cm,aspect=1.0,draw]{A};
            \end{tikzpicture}
\end{document} 
5

Here is a proposal. I replace example-image-a by \includegraphics[width=9mm]{example-image-a}, really make use of positioning and draw the cylinder.

\documentclass{article}
\usepackage{xcolor}
\definecolor{mycolor}{RGB}{8,108,131}
\usepackage{tikz} 
\usetikzlibrary{positioning}
\usetikzlibrary{backgrounds}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{calc}
\tikzset{cylinder end fill/.style={path picture={
\pgftransformshift{\centerpoint}%
\pgftransformrotate{\rotate}%  
\pgfpathmoveto{\beforetop}%
\pgfpatharc{90}{-270}{\xradius and \yradius}%
\pgfpathclose
\pgfsetfillcolor{#1}%
\pgfusepath{fill}}
}}
\begin{document}
 \begin{tikzpicture}[scale=0.8,
     transform shape,
     show background rectangle,
     %background rectangle/.style={fill=gray!10},
     box/.style={draw, font=\itshape}
       ]
     \coordinate (b) at (current page.center);
     \node [
         label=right:xx, 
     ] (firewall)at(b) {\includegraphics[width=9mm]{example-image-a}};
     \node [label=above:Client,below=1.5cm of firewall] 
     (client) {\includegraphics[width=9mm]{example-image-a}};
     \node [label=below:xx,left=4.5cm of firewall] 
     (dnsServer)  {\includegraphics[width=9mm]{example-image-a}};
     \node [label=center:Internet,below=1.5cm of client]
      (cloud) {\includegraphics[width=9mm]{example-image-a}};
     \node [below left=1.5cm and 0.5cm of cloud,label=below:xx]
      (server1) {\includegraphics[width=9mm]{example-image-a}};
     \node [below right=1.5cm and 0.5cm of cloud,
         label=right:example.com] (server2) 
         {\includegraphics[width=9mm]{example-image-a}};
     \draw [thick,mycolor,->](client) .. controls  (firewall) .. (dnsServer)node[very near start, left]{1};
     \draw [thick,mycolor,->](dnsServer) .. controls (firewall)and (cloud) .. (server1)node[very near end, left]{2};
     \draw [thick,mycolor,->](server1) .. controls  (cloud) and (firewall)..  (client)node[very near start, right]{5};
     \path[mycolor,->] (client) edge  [loop right] node {6} ();
     \begin{scope}[on background layer]
     \path let \p1=($(server1)-(client)$),
     \n1={atan2(\y1,\x1)},\n2={veclen(\y1,\x1)} in
     node[cylinder, rotate=\n1+180,
     minimum height=0.85*\n2,minimum width=1cm,aspect=1.0,
     cylinder end fill=blue,
     left color=blue!30,right color=black,middle color=blue!80,
     shading angle=\n1,draw] at ($(server1)!0.5!(client)$) {A};
     \end{scope}
 \end{tikzpicture}
\end{document} 

enter image description here

  • My bad, I didn't check before posting. Anyway thx for the help :) – Warok Jan 12 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.