11

I would like to imitate the following formatting.

enter image description here

The randomness of the styles should be adjustable by indicating the seed used so that the same diagram is always repeated if necessary.

I would also like to have the same vertical distances between the nodes automatically if possible.

Here is a starting code.

\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} 
7
  • see tex.stackexchange.com/q/39296/36296 or tex.stackexchange.com/questions/74878/… for some starting points Commented Dec 28, 2022 at 10:41
  • 1
    And \tikzstyle is obsolete. Use \tikzset instead Commented Dec 28, 2022 at 10:42
  • 1
    Re distance between nodes: Use the positioning library and its keys <placement>=of <reference>` instead of <placement> of=<reference>. [1], [2]. If you have figured out the randomness and the decorations you will have to do the drawing and the filling separately since they describe different paths: preaction/postaction. Commented Dec 28, 2022 at 11:04
  • 1
    That said, the real challenge will be to setup the decorations. sometimes the sides of the rectangle are straight but drawn separately. Sometimes two of them meet in the corner, some are connected with a big arc. Some are straight, some are tilted slightly. Some sides are interrupted. The calligraphy library might help with the varying line width. Commented Dec 28, 2022 at 11:07
  • 1
    I haven't tested it but instead of drawing the border, you should be able to use the option use pen on it after you've defined a \pen, of course and have loaded the calligraphy library. Commented Jan 6, 2023 at 3:27

1 Answer 1

20
+50

Well, it's not exactly like your image, but it's a (relatively) easy solution using random steps from the decorations.pathmorphing library. As a preaction the nodes are filled, but with different settings from the way they are drawn. You can adjust those however you like.

The arrows are actually two superimposed arrows (yellow on black) with the second drawn shorter and thinner than the first as a postaction.

I used chains to fix the distance between nodes. Then every join can be set to the connection style.

enter image description here

\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} 
3
  • 1
    The output is very good. Thanks for this! Commented Dec 29, 2022 at 20:11
  • Is there a way to select the seed for randomness? Commented Dec 29, 2022 at 20:47
  • 1
    @projetmbc: I think you can use \pgfmathsetseed. I edited my response with an example. Commented Dec 29, 2022 at 22:46

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.