我想制作如下的工作流程图:
我找到了 TikZ,但是序列图示例似乎有点晦涩……
答案1
您可以将此用作起点:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes}
\begin{document}
\begin{tikzpicture}[head/.style={line width=2pt,draw=gray,rounded corners=8pt,text width=2cm,align=center}]
\node[head,fill=green!60!black!50] (wd) {working directory};
\node[head,fill=yellow!40,right=of wd] (sa) {staging \\ area};
\node[head,fill=blue!40,right=of sa] (lr) {local \\ repo};
\node[head,fill=red!40,right=2cm of lr] (rr) {remote \\ repo};
\begin{scope}[line width=2pt,gray]
\foreach \x in {wd,sa,lr,rr}
\draw ([yshift=-5pt]\x.south) -- +(0,-7cm);
\end{scope}
\begin{scope}[every node/.style={single arrow, draw=none,fill=red!50,anchor=west,align=center}]
\node [anchor=west,text width=2.8cm] at ([yshift=-1cm]wd.south) {git add};
\node [anchor=west,text width=2.8cm] at ([yshift=-2cm]sa.south) {git commit};
\node [anchor=west,text width=3.8cm] at ([yshift=-3cm]lr.south) {git push};
\node [anchor=east,text width=3.8cm,shape border rotate=180] at ([yshift=-4cm]rr.south) {git fetch};
\node [anchor=east,text width=6.1cm,shape border rotate=180] at ([yshift=-5cm]lr.south) {git checkout};
\node [anchor=east,text width=6.1cm,shape border rotate=180] at ([yshift=-6cm]lr.south) {git merge};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
差不多稍后了,但是这在某种程度上解决了背景问题(说实话,我在箭头和颜色方面玩得太多了:)
)。
\documentclass[svgnames]{article}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,shapes.arrows,shadows,backgrounds, positioning}
\tikzset{bubble/.style={rectangle, draw=gray,rounded corners,fill=#1,align = flush center,minimum height=1cm,minimum width=1.75cm}}
\tikzfading [name=arrowfading, top color=transparent!0, bottom color=transparent!95]
\tikzset{arrowfill/.style={top color=OrangeRed!20, bottom color=Red, general shadow={fill=black, shadow yshift=-0.8ex, path fading=arrowfading}}}
\tikzset{arrowstyle/.style={draw=FireBrick,arrowfill, single arrow,minimum height=#1, single arrow,
single arrow head extend=.4cm,}}
\begin{document}
\begin{tikzpicture}
% Bubbles
\node[bubble=ForestGreen!40] (wd) at (0,0) {working\\directory};
\node[bubble=Gold!40] (sa) at (2.5,0) {staging\\area};
\node[bubble=DodgerBlue!40] (lc) at (5,0) {local repo};
\node[bubble=Tomato!40] (rc) at (8.5,0) {remote repo};
\node[above= 1 cm of rc,font={\bf}]{Remote};
\node[above= 1 cm of sa,font={\bf}]{Local};
% Lines
\foreach \bubble in {wd,sa,lc,rc}
\draw[ultra thick, gray] ($(\bubble.south)-(0,0.25)$)--($(\bubble.south)-(0,9)$);
% Arrows
\node [arrowstyle=2.5cm,xshift=-0.1cm,yshift=-1.5cm] at ($(wd.south)!0.5!(sa.south)$) {git add};
\node [arrowstyle=2.5cm,xshift=-0.1cm,yshift=-2.5cm] at ($(sa.south)!0.5!(lc.south)$) {git commit};
\node [arrowstyle=3.5cm,xshift=-0.1cm,yshift=-3.5cm] at ($(lc.south)!0.5!(rc.south)$) {git push};
\node [arrowstyle=3.5cm,xshift=0.1cm,yshift=-5cm,shape border rotate=180] at ($(rc.south)!0.5!(lc.south)$) {git fetch};
\node [arrowstyle=5cm,xshift=0.1cm,yshift=-6.5cm,shape border rotate=180] at ($(lc.south)!0.5!(wd.south)$) {git checkout};
\node [arrowstyle=5cm,xshift=0.1cm,yshift=-8cm,shape border rotate=180] at ($(lc.south)!0.5!(wd.south)$) {git merge};
% Background
\begin{pgfonlayer}{background}
\fill[gray!10]($(lc.north)!0.5!(rc.north)+(0,0.5)$)rectangle($(lc.south)!0.5!(rc.south)+(4,-9.5)$) ;
\draw[dashed, shorten <=-1.5cm] ($(lc.south)!0.5!(rc.south)$)--($(lc.south)!0.5!(rc.south)-(0,9.5)$);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
结果:
绘制此类图片的另一种可能性是利用pgfgantt
包裹。