| 1 |
\documentclass[class=minimal]{standalone} |
| 2 |
|
| 3 |
\usepackage{tikz} |
| 4 |
\usetikzlibrary{shapes.geometric} |
| 5 |
\newcommand{\tiny}[1]{\scalebox{0.45}{#1}} |
| 6 |
|
| 7 |
\begin{document} |
| 8 |
|
| 9 |
\begin{tikzpicture} |
| 10 |
|
| 11 |
\tikzstyle{title}=[text width=1.1cm, inner sep=0pt] |
| 12 |
\tikzstyle{square}=[rectangle, draw, minimum width=0.5cm, minimum height=0.5cm, inner sep=0pt, fill opacity=0.5, text opacity=1] |
| 13 |
\tikzstyle{op}=[ellipse, draw, inner sep=-1pt, minimum height=9pt, minimum width=12pt] |
| 14 |
\tikzstyle{edge}=[->] |
| 15 |
\tikzstyle{round}=[out=-90, in=90, looseness=0.85] |
| 16 |
|
| 17 |
\node[title] at (-0.8, 2.2) {index}; |
| 18 |
\node[title] at (-0.8, 1.5) {input}; |
| 19 |
\foreach \i in {0,...,\numberInputs} { |
| 20 |
\pgfmathparse{\indices[\i]}\let\idx\pgfmathresult |
| 21 |
\pgfmathparse{\inputs[\i]}\let\in\pgfmathresult |
| 22 |
\pgfmathparse{\colors[\idx]}\let\co\pgfmathresult |
| 23 |
\node[square] (index\i) at (\i * 0.5, 2.2) {\idx}; |
| 24 |
\node[square, fill=\co] (input\i) at (\i * 0.5, 1.5) {\in}; |
| 25 |
\draw[edge] (index\i) -- (input\i); |
| 26 |
} |
| 27 |
|
| 28 |
\node[title] at (-0.8, 0.0) {out}; |
| 29 |
\foreach \i in {0,...,\numberOutputs} { |
| 30 |
\pgfmathparse{\outputs[\i]}\let\out\pgfmathresult |
| 31 |
\pgfmathparse{\colors[\i]}\let\co\pgfmathresult |
| 32 |
\def \x{(\numberInputs - \numberOutputs) * 0.25 + \i * 0.5} |
| 33 |
\node[op] (op\i) at ({\x}, 0.6) {\tiny{\operation}}; |
| 34 |
\node[square, fill=\co] (output\i) at ({\x}, 0.0) {\out}; |
| 35 |
\draw[edge] (op\i) -- (output\i); |
| 36 |
} |
| 37 |
|
| 38 |
\foreach \i in {0,...,\numberInputs} { |
| 39 |
\pgfmathparse{\indices[\i]}\let\idx\pgfmathresult |
| 40 |
\draw[edge] (input\i) to[round] (op\idx); |
| 41 |
} |
| 42 |
|
| 43 |
\end{tikzpicture} |
| 44 |
|
| 45 |
\end{document} |