TikZ-“手形”风格的流程图

TikZ-“手形”风格的流程图

我想模仿以下格式。

在此处输入图片描述

样式的随机性应该是可以通过指示所使用的种子来调整的,以便在必要时始终重复相同的图表。

如果可能的话,我还希望节点之间自动具有相同的垂直距离。

这是一个起始代码。

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes, arrows}


\begin{document}

% The styles
\tikzset{
    block/.style = {
        rectangle, draw, 
        text width=5em, text centered, 
        minimum height=4em
    },
    connection/.style={
        draw, 
        -latex'
    }
}

    
\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [block] (lint) 
          {Lint};
    \node [block, below of = lint] (run) 
          {Run unit and integration tests};
    \node [block, below of = run] (build) 
          {Build image};
    \node [block, below of = build] (upload) 
          {Upload image to registry};
    \node [block, below of = upload, node distance=2.5cm] (update) 
          {Update running service to use new image};
    % Draw arrows.
    \path [connection] (lint)   -- (run);
    \path [connection] (run)    -- (build);
    \path [connection] (build)  -- (upload);
    \path [connection] (upload) -- (update);
\end{tikzpicture}

\end{document}

答案1

嗯,它并不完全像您的图片,但它是库random steps中的一个(相对)简单的解决方案decorations.pathmorphingpreaction节点已填充,但设置与绘制方式不同。您可以随意调整它们。

这两个箭头实际上是两个叠加的箭头(黑底黄色),第二支箭头比第一支箭头更短更细postaction

我习惯chains将节点之间的距离固定。然后every join可以设置为connection样式。

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows.meta, decorations.pathmorphing, chains}

\begin{document}

% The styles
\tikzset{
    block/.style = {join,
        rectangle, draw, line width=2pt, 
        text width=3cm, text centered, 
        minimum height=1.5cm, rounded corners,
        decorate, decoration={random steps, segment length=6mm, amplitude=1pt},
        preaction={fill=#1, rectangle, 
        minimum width=3cm, 
        minimum height=1.5cm, rounded corners,
        decorate, decoration={random steps, segment length=3mm, amplitude=2mm}
        }
    },
    connection/.style={
        shorten >=2pt, shorten <=2pt,
        -{Stealth[length=2mm, inset=0, width=4mm, round]},
        line width=1.5mm,
        decorate, decoration={random steps, segment length=4pt, amplitude=.1pt},
        postaction={draw, yellow, shorten <=3pt, shorten >=3.5pt, line width=1mm,
            -{Stealth[length=1.1mm, inset=0, width=2.5mm, round]}}
    }
}

\begin{tikzpicture}[start chain=going below, node distance = 6mm, every join/.style=connection]
\pgfmathsetseed{14159}
    \node [on chain, block=blue!30!green!70!white] (lint) {Lint};
    \node [on chain, block=blue!40!green!70!white] (run) {Run unit and integration tests};
    \node [on chain, block=blue!50!green!70!white] (build) {Build image};
    \node [on chain, block=blue!60!green!70!white] (upload) {Upload image to registry};
    \node [on chain, block=blue!70!green!70!white] (update) {Update running service to use new image};
\end{tikzpicture}

\end{document}

相关内容