-
-
Save yitsushi/39c544191c58e1b41abce60bff9c7ef4 to your computer and use it in GitHub Desktop.
Simple Communication Diagram with LaTeX with a template structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
├── fonts | |
│ └── Sauce Code Pro Nerd Font Complete.ttf | |
├── proposal | |
│ └── proposal-0001 | |
│ └── readme.md | |
├── scripts | |
│ └── generate-tex | |
└── src | |
├── proposal | |
│ └── proposal-0001 | |
│ └── flow.tex | |
└── template.tex | |
./scripts/generate-tex | |
. | |
├── fonts | |
│ └── Sauce Code Pro Nerd Font Complete.ttf | |
├── proposal | |
│ └── proposal-0001 | |
│ ├── assets | |
│ │ ├── flow-fill.png | |
│ │ └── flow.png | |
│ └── readme.md | |
├── scripts | |
│ └── generate-tex | |
└── src | |
├── proposal | |
│ └── proposal-0001 | |
│ └── flow.tex | |
└── template.tex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\begin{document} | |
\begin{tikzpicture}[ | |
draw=foreground, text=foreground, | |
label/.style={pos=0.5,above,font=\tiny, sloped} | |
] | |
\newcommand{\height}{5}; | |
\newcommand{\webui}{0}; | |
\newcommand{\gitops}{5}; | |
\newcommand{\mngc}{10}; | |
\newcommand{\leafca}{15}; | |
\layer{\webui} {\height} {Web UI}; | |
\layer{\gitops} {\height} {Backe-end}; | |
\layer{\mngc} {\height} {Agent}; | |
\layer{\leafca} {\height} {Cluster}; | |
\arrow{\webui}{\gitops}{4}{List all Releases}{label}; | |
\arrowstream{\gitops}{\webui}{1}{0.5}{Stream}{label}; | |
\arrow{\gitops}{\mngc}{3.5}{List all Releases} {label}; | |
\draw[dotted] (\mngc, 2.75) -- (7.5, 2.75); | |
\draw[dotted] (7.5, 2.75) -- (7.5, 1) | |
node [label, rotate=180] {Stream}; | |
\arrowstream{7.5}{\gitops}{1}{1}{}{}; | |
\arrow{\mngc}{\leafca}{3} | |
{List all Releases}{label}; | |
\draw[dotted] (\mngc, 2.5) -- (7.5, 2.5); | |
\arrowstream{\leafca}{\mngc}{2.5}{2.5} | |
{List of events (Releases)}{label}; | |
\arrowstream{\leafca}{\mngc}{2}{2} | |
{New events (Release)}{label}; | |
\arrowstream{\leafca}{\mngc}{1.5}{1.5} | |
{New events (Release)}{label}; | |
\draw[dotted] (\mngc,2) -- (7.5, 2); | |
\draw[dotted] (\mngc,1.5) -- (7.5, 1.5); | |
% Add a bit of margin ;) | |
\node[yshift=1em, xshift=-2em] at (0, \height) {}; | |
\node[yshift=-1em, xshift=2em] at (\leafca, 0) {}; | |
\end{tikzpicture} | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
scope="${1:-src}" | |
tmpDir=$(mktemp -d) | |
fontDir="$(git rev-parse --show-toplevel)/fonts/" | |
if [[ "${scope}" != src* ]]; then | |
scope="src/${scope}" | |
fi | |
trap "rm -rf ${tmpDir}" EXIT | |
for file in $(find ${scope} -name "*.tex" -not -name 'template.tex'); do | |
filePath=$(dirname $file | sed -e 's#^src/##') | |
tmpPath="${tmpDir}/${filePath}" | |
fileName="$(basename ${file} '.tex')" | |
mkdir -p "${tmpPath}" | |
echo -en " \U1F550 ${filePath}/${fileName}.tex ..." | |
cat src/template.tex \ | |
| sed -e "s#@@TARGET@@#${file}#" \ | |
-e "s#@@FONTPATH@@#${fontDir}#" \ | |
-e "s#@@IMGPATH@@#$(pwd)/src/${filePath}/#" \ | |
| xelatex \ | |
-output-directory="${tmpPath}" \ | |
-jobname="${fileName}" \ | |
> /dev/null | |
ret=$? | |
if false; then | |
if [ -n $ret ]; then | |
echo "" | |
cat "${tmpPath}/${fileName}.log" | |
# exit | |
fi | |
fi | |
convert \ | |
-density 300 \ | |
"${tmpPath}/${fileName}.pdf" \ | |
-quality 90 \ | |
"${tmpPath}/${fileName}.png" | |
convert \ | |
-density 300 \ | |
"${tmpPath}/${fileName}.pdf" \ | |
-quality 90 \ | |
-background "#292a2d" \ | |
-flatten \ | |
"${tmpPath}/${fileName}-fill.png" | |
mkdir -p "${filePath}/assets" | |
cp "${tmpPath}/${fileName}.png" "${filePath}/assets/" | |
cp "${tmpPath}/${fileName}-fill.png" "${filePath}/assets/" | |
echo -e "\r \U2705 ${filePath}/${fileName}.tex -> ${filePath}/${fileName}[-fill].png" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{standalone} | |
\usepackage{tikz} | |
\usepackage{transparent} | |
\usepackage{fontspec} | |
\usepackage{xcolor} | |
\usepackage{graphicx} | |
\usepackage{anyfontsize} | |
\setmainfont{Umpush-Light.otf} | |
\setmonofont{Sauce Code Pro Nerd Font Complete.ttf}[ | |
Path = @@FONTPATH@@ | |
] | |
\usetikzlibrary{calc, backgrounds, positioning, matrix} | |
\graphicspath{{@@IMGPATH@@}} | |
\newcommand{\layer}[3]{ | |
\node[draw] (top) at (#1, #2) {#3}; | |
\node[draw] (bottom) at (#1, 0) {#3}; | |
\draw (top.south) -| (bottom.north); | |
} | |
\newcommand{\arrow}[5]{ | |
\draw[-stealth] (#1, #3) -- (#2, #3) node [#5] {#4}; | |
} | |
\newcommand{\arrowstream}[6]{ | |
\draw[-stealth, dotted] (#1, #3) -- (#2, #4) node [#6] {#5}; | |
} | |
\definecolor{foreground}{RGB}{149, 149, 159} | |
\definecolor{background}{RGB}{41, 42, 45} | |
\input{@@TARGET@@} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Single file format: https://gist.github.com/yitsushi/ce4c6ef2bb749fc4bb77c5127ac90ca8