是否有用于网络符号的 Tikz 库?

是否有用于网络符号的 Tikz 库?

是否有用于网络符号的 Tikz 库?

例如:

  • 服务器
  • 数据库
  • 防火墙
  • 个人电脑
  • 笔记本电脑
  • ETC...

答案1

要使用 TikZ 绘制网络图,您可以使用

下面是一个示例,我在其中绘制了一个路由器拓扑。路由器图标的灵感来自阴影圆柱体作者:Jan Hlavacek。箭头形节点表示传入和传出的路线。对于接口和标签,形状是定义的。因此,可以很容易地一次性自定义所有绘图细节。

具有三个路由器的网络拓扑

\documentclass{article}
\usepackage[hmargin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc, shadings, shadows, shapes.arrows}

% Styles for interfaces and edge labels
\tikzset{%
  interface/.style={draw, rectangle, rounded corners, font=\LARGE\sffamily},
  ethernet/.style={interface, fill=yellow!50},% ethernet interface
  serial/.style={interface, fill=green!70},% serial interface
  speed/.style={sloped, anchor=south, font=\large\sffamily},% line speed at edge
  route/.style={draw, shape=single arrow, single arrow head extend=4mm,
    minimum height=1.7cm, minimum width=3mm, white, fill=blue!20,
    drop shadow={opacity=.8, fill=blue!50!black}, font=\tiny}% inroute / outroute arrows
}
\newcommand*{\shift}{1.3cm}% For placing the arrows later

% The router icon
\newcommand*{\router}[1]{
\begin{tikzpicture}    
  \coordinate (ll) at (-3,0.5);
  \coordinate (lr) at (3,0.5);
  \coordinate (ul) at (-3,2);
  \coordinate (ur) at (3,2);
  \shade [shading angle=90, left color=black!40!blue, right color=white] (ll)
    arc (-180:-60:3cm and .75cm) -- +(0,1.5) arc (-60:-180:3cm and .75cm)
    -- cycle;
  \shade [shading angle=270, right color=black!40!blue, left color=white!50] (lr)
    arc (0:-60:3cm and .75cm) -- +(0,1.5) arc (-60:0:3cm and .75cm) -- cycle;
  \draw [thick] (ll) arc (-180:0:3cm and .75cm) -- (ur) arc (0:-180:3cm and .75cm)
    -- cycle;
  \draw [thick, shade, upper left=blue!30!black, lower left=blue!80!white,
    upper right=blue!80!white, lower right=white] (ul)
    arc (-180:180:3cm and .75cm);
  \node at (0,0.5){\color{blue!60!black}\Huge #1};% The name of the router
  % The four arrows, symbols for incoming and outgoing routes:
  \begin{scope}[yshift=2cm, yscale=0.28, transform shape]
    \node[route, rotate=45, xshift=\shift] {\strut};
    \node[route, rotate=-45, xshift=-\shift] {\strut};
    \node[route, rotate=-135, xshift=\shift] {\strut};
    \node[route, rotate=135, xshift=-\shift] {\strut};
  \end{scope}
\end{tikzpicture}}

\begin{document}
\pagestyle{empty}
\centering
\begin{tikzpicture}[node distance=10cm]
  % Place three routers as nodes:
  \node (R1) {\router{R1}};
  \node [right of=R1] (R2) {\router{R2}};
  \node[yshift=6cm] at ($ (R1) !.5! (R2) $)  (R3) {\router{R3}};
  % Connect by lines and specify interfaces and speed:
  \draw[thick] (R1)
    -- node[ethernet,  at start]{eth0} node[ethernet, at end] {eth0} (R2)
      node[speed,midway] {100 Mbps}
    -- node[serial,  at start]{S0} node[serial, at end] {S1} (R3)
      node[speed,midway] {115200 bps}
    -- node[serial,  at start]{S0} node[serial, at end] {S0} (R1)
      node[speed,midway] {64000 bps};
\end{tikzpicture}
\end{document}

答案2

moeptikz 提供了许多易于使用的符号来创建网络图形。

https://github.com/moepinet/moeptikz

它用于 TUM 的网络讲座。

相关内容