1

Is it possible to add an offset to the control points of the bezier curves to make my red line to pass through the center of the point cloud? Here is my mwe:

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz} 
    \usetikzlibrary{chains}
    \usetikzlibrary{positioning}
    \usetikzlibrary{backgrounds}
    \usetikzlibrary{trees}

\usetikzlibrary{arrows,automata}
\usepackage{epstopdf}
\definecolor{mycolor}{RGB}{8,108,131}
\usepackage{array}
\usepackage{adjustbox}      
\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:XXX, 
        ] (firewall)at(b) {\includegraphics[width=9mm]{example-image-a}};
        \node [
            label=above:XXX
        ] (client) at ([yshift=2cm]firewall){\includegraphics[width=9mm]{example-image-a}};
        \node [
            label=XXX
        ] (dnsServer)  at([xshift=-5cm]firewall){\includegraphics[width=9mm]{example-image-a}};
       \node [
            label=center:XXX,
        ] (cloud) at ([yshift=-2cm]firewall){\includegraphics[width=9mm]{example-image-b}};
        \node [
            label=below:XXX
        ] (server1) at([xshift=5cm]cloud){\includegraphics[width=9mm]{example-image-a}};
        \node [
            label=right:XXX
        ] (server2) at([xshift=5cm]server1){\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)--(server2)node[midway,above]{3 et 4};
        \draw [thick,mycolor,->](server1) .. controls  (cloud) and (firewall)..  (client)node[very near start, right]{5};
        \draw [thick,red,->](client) .. controls  (firewall) and (cloud)..  (server1)node[]{};
        \path[mycolor,->] (client) edge  [loop right] node {6} ();
    \end{tikzpicture}
\end{document} 

And here is the output: Output

  • 1
    If this is what you want, then just set both the control in the red line to cloud: .. controls (cloud) .. in place of .. controls (firewall) and (cloud) ... – Partha D. Jan 28 at 12:54
  • Oky, this will do it, but is there any option to add an offset? – Warok Jan 28 at 15:38
2

Is that close to what you are asking for:

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz} 
    \usetikzlibrary{chains}
    \usetikzlibrary{positioning}
    \usetikzlibrary{backgrounds}
    \usetikzlibrary{trees}

\usetikzlibrary{arrows,automata}
\usepackage{epstopdf}
\definecolor{mycolor}{RGB}{8,108,131}
\usepackage{array}
\usepackage{adjustbox}      
\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:XXX, 
        ] (firewall)at(b) {\includegraphics[width=9mm]{example-image-a}};
        \node [
            label=above:XXX
        ] (client) at ([yshift=2cm]firewall){\includegraphics[width=9mm]{example-image-a}};
        \node [
            label=XXX
        ] (dnsServer)  at([xshift=-5cm]firewall){\includegraphics[width=9mm]{example-image-a}};
       \node [
            %label=center:XXX,
        ] (cloud) at ([yshift=-2cm]firewall){\includegraphics[width=9mm]{example-image-b}};
        \node [
            label=below:XXX
        ] (server1) at([xshift=5cm]cloud){\includegraphics[width=9mm]{example-image-a}};
        \node [
            label=right:XXX
        ] (server2) at([xshift=5cm]server1){\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)--(server2)node[midway,above]{3 et 4};
        \draw [thick,mycolor,->](server1) .. controls  (cloud) and (firewall)..  (client)node[very near start, right]{5};
        \draw [thick,red,->](client) .. controls  ([yshift=-2.5cm]firewall) and ([xshift=-1cm]cloud)..  (server1)node[]{};
        \path[mycolor,->] (client) edge  [loop right] node {6} ();
    \end{tikzpicture}
\end{document} 
  • @Warok Pleased to know that your problem is fixed – Hafid Boukhoulda Jan 29 at 10:50
3

While @Hafid Boukhoulda gives a flexible, general approach for offset, setting both the control points to the same point (cloud) makes the Beizer curve look smooth, simple and beautiful -- and hence could be another choice to consider if it meets your requirements.

enter image description here

...for which I used the code:

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz} 
  \usetikzlibrary{chains}
  \usetikzlibrary{positioning}
  \usetikzlibrary{backgrounds}
  \usetikzlibrary{trees}

\usetikzlibrary{arrows,automata}
\usepackage{epstopdf}
\definecolor{mycolor}{RGB}{8,108,131}
\usepackage{array}
\usepackage{adjustbox}    
\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:XXX] 
       (firewall)at(b) {\includegraphics[width=9mm]{example-image-a}};
    \node [label=above:XXX] 
       (client) at ([yshift=2cm]firewall){\includegraphics[width=9mm]{example-image-a}};
    \node [label=XXX]
       (dnsServer)  at([xshift=-5cm]firewall){\includegraphics[width=9mm]{example-image-a}};
    \node [label=center:{}]
       (cloud) at ([yshift=-2cm]firewall){\includegraphics[width=9mm]{example-image-b}};
    \node [label=below:XXX]
       (server1) at([xshift=5cm]cloud){\includegraphics[width=9mm]{example-image-a}};
    \node [label=right:XXX]
       (server2) at([xshift=5cm]server1){\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)--(server2)node[midway,above]{3 et 4};
    \draw [thick,mycolor,->](server1) .. controls  (cloud) and (firewall)..  (client)node[very near start, right]{5};
    \draw [thick,red,->](client) .. controls (cloud) ..  (server1)node[]{};
                        % only one control (cloud) instead of two
    \path[mycolor,->] (client) edge  [loop right] node {6} ();
  \end{tikzpicture}
\end{document} 

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.