From a8dc6dc2107b092b4e3feef2eef5978bdb587eee Mon Sep 17 00:00:00 2001 From: Hendrik Kleinwaechter Date: Sat, 19 Aug 2023 16:35:02 +0200 Subject: [PATCH] Change flowchart color (#185) * Change BG color to white * Fix flowcharts where graphics overlap with text * Increase border size * change arrow style * Allow standalone building of TikZ flowcharts Useful for reference or website etc.. * Prevent manual hyphenation in TikZ diagrams A Bit of a manual tweak.. but worth it to look nicer :D * Add missing file for flowcharts --------- Co-authored-by: Cedric --- book/colors.tex | 12 +++++++ book/figures/export_figures.sh | 19 ++++++---- book/figures/fig-bulk-fermentation.tex | 2 +- book/figures/fig-dutch-oven-process.tex | 2 +- book/figures/fig-kneading-process.tex | 4 +-- .../figures/fig-liquid-starter-conversion.tex | 2 +- book/figures/fig-starter-process.tex | 4 +-- book/figures/fig-starter-readiness.tex | 4 +-- book/figures/fig-stiff-starter-conversion.tex | 8 ++--- book/figures/flowcharts_tikz.tex | 21 +++++++++++ book/figures/vars.tex | 13 ++----- book/makefile | 10 +++--- book/sourdough.sty | 35 +++---------------- 13 files changed, 73 insertions(+), 63 deletions(-) create mode 100644 book/colors.tex create mode 100644 book/figures/flowcharts_tikz.tex diff --git a/book/colors.tex b/book/colors.tex new file mode 100644 index 0000000..a02e515 --- /dev/null +++ b/book/colors.tex @@ -0,0 +1,12 @@ +\definecolor{codeblue}{RGB}{69, 161, 248} +\definecolor{codeblack}{RGB}{40, 40, 40} + +\definecolor{maingray}{HTML}{F8F8F8} + +\definecolor{hlocre}{HTML}{E5B874} +\definecolor{hlorange}{HTML}{EC7850} +\definecolor{hlyellow}{HTML}{FAE69E} + +\definecolor{pinkpic}{RGB}{246, 183, 194} +\definecolor{redpic}{RGB}{232, 72, 71} +\definecolor{yellowpic}{RGB}{246, 235, 51} diff --git a/book/figures/export_figures.sh b/book/figures/export_figures.sh index bbafe50..a4eef16 100755 --- a/book/figures/export_figures.sh +++ b/book/figures/export_figures.sh @@ -1,8 +1,15 @@ #!/bin/bash -for i in *.pdf -do - docker run -v $(pwd):/imgs dpokidov/imagemagick -density 900 -trim /imgs/$i -quality 100 /imgs/$i.png - rename 's/pdf.png/png/' *.png - rename 's/fig-/figure-/' *.png -done +# +if [ "$#" -ne 1 ]; then + for i in *.pdf + do + target=figures/`basename $1 .png.pdf`.png + docker run -v $(pwd):/imgs dpokidov/imagemagick -density 900 -trim /imgs/$i -quality 100 /imgs/${target} + rename 's/fig-/figure-/' *.png + done +else + target=figures/`basename $1 .png.pdf`.png + echo "Converting: " $1 " to: " ${target} + convert -density 900 -trim $1 -quality 100 ${target} +fi diff --git a/book/figures/fig-bulk-fermentation.tex b/book/figures/fig-bulk-fermentation.tex index fc2e235..402997f 100644 --- a/book/figures/fig-bulk-fermentation.tex +++ b/book/figures/fig-bulk-fermentation.tex @@ -7,7 +7,7 @@ \node [decision, right of=ph_value, node distance=4cm] (dough_ready) {\footnotesize Dough ready?}; \node [success, below of=dough_ready] (divide_preshape) {\footnotesize Divide and preshape}; \node [decision, below of=smell] (dough_flattened) {\footnotesize Dough flattened out?}; - \node [block, below of=check_dough, node distance=3cm] (wait_60_minutes) {\footnotesize Wait 60~minutes}; + \node [block, below of=check_dough, node distance=3cm] (wait_60_minutes) {\footnotesize Wait\\ 60~minutes}; \node [block, below of=wait_60_minutes, node distance=4cm] (stretch_fold) {\footnotesize Stretch and fold}; \path [line] (init) -- (check_dough); diff --git a/book/figures/fig-dutch-oven-process.tex b/book/figures/fig-dutch-oven-process.tex index d24772c..22e536a 100644 --- a/book/figures/fig-dutch-oven-process.tex +++ b/book/figures/fig-dutch-oven-process.tex @@ -7,7 +7,7 @@ \node [block, below of=spritz] (close) {\footnotesize Close DO}; \node [block, left of=close] (back_oven) {\footnotesize Place DO back in oven}; \node [block, left of=back_oven] (bake) {\footnotesize Bake 30~minutes at \qty{230}{\degreeCelsius} (\qty{446}{\degF})}; - \node [block, below of=heat_oven] (wait_5_minutes) {\footnotesize Wait 5 minutes}; + \node [block, below of=heat_oven] (wait_5_minutes) {\footnotesize Wait\\ 5 minutes}; \node [decision, below of=wait_5_minutes, node distance=4cm] (is_ready_check) {\footnotesize Core temperature \qty{92}{\degreeCelsius} (\qty{197}{\degF})?}; \node [block, right of=is_ready_check, node distance=4cm] (remove_do_lid) {\footnotesize Remove DO lid}; \node [block, right of=wait_5_minutes] (test_temperature_again) {\footnotesize Test core temperature again}; diff --git a/book/figures/fig-kneading-process.tex b/book/figures/fig-kneading-process.tex index 8ee5981..703c431 100644 --- a/book/figures/fig-kneading-process.tex +++ b/book/figures/fig-kneading-process.tex @@ -1,10 +1,10 @@ \begin{tikzpicture}[node distance = 3cm, auto] \node [start] (init) {\footnotesize Homogenize recipe ingredients}; - \node [block, right of=init, node distance=3cm] (wait1) {\footnotesize Wait 15~minutes}; + \node [block, right of=init, node distance=3cm] (wait1) {\footnotesize Wait\\15~minutes}; \path [line] (init) -- (wait1); \node [block, right of=wait1, node distance=3cm] (knead1) {\footnotesize Knead 5~minutes}; \path [line] (wait1) -- (knead1); - \node [block, right of=knead1, node distance=3cm] (wait2) {\footnotesize Wait 15~minutes}; + \node [block, right of=knead1, node distance=3cm] (wait2) {\footnotesize Wait\\15~minutes}; \path [line] (knead1) -- (wait2); \node [decision, below of=wait2, node distance=3cm] (windowpane_test) {\footnotesize Window-pane?}; \path [line] (wait2) -- (windowpane_test); diff --git a/book/figures/fig-liquid-starter-conversion.tex b/book/figures/fig-liquid-starter-conversion.tex index 811c3c6..9c0c2c4 100644 --- a/book/figures/fig-liquid-starter-conversion.tex +++ b/book/figures/fig-liquid-starter-conversion.tex @@ -1,7 +1,7 @@ \begin{tikzpicture}[node distance = 3cm, auto] \node [start] (init) {\footnotesize Make a regular or stiff starter}; \node [block, right of=init] (feed_new_ratio) {\footnotesize Mix \qty{1}{\gram} existing starter, \qty{5}{\gram} flour and \qty{25}{\gram} water}; - \node [block, right of=feed_new_ratio] (next_day) {\footnotesize Wait \qty{24}{\hour}}; + \node [block, right of=feed_new_ratio] (next_day) {\footnotesize Wait\\ \qty{24}{\hour}}; \node [block, below of=init, node distance=4cm] (feed_again) {\footnotesize Feed again using 1:5:25 ratio}; \node [block, right of=next_day, node distance=5cm] (test) {\footnotesize Check starter readiness?}; \node [decision, below of=next_day, node distance=4cm] (ready_signs) {\footnotesize Sour yogurty smell and bubbles visible on flour?}; diff --git a/book/figures/fig-starter-process.tex b/book/figures/fig-starter-process.tex index eeecc2c..1acae9a 100644 --- a/book/figures/fig-starter-process.tex +++ b/book/figures/fig-starter-process.tex @@ -1,6 +1,6 @@ \begin{tikzpicture}[node distance = 3cm, auto] \node [start] (init) {\footnotesize Mix \qty{50}{\gram} flour + \qty{50}{\gram} water, stir}; - \node [block, right of=init, node distance=3cm] (wait1) {\footnotesize Wait \qty{24}{\hour}}; + \node [block, right of=init, node distance=3cm] (wait1) {\footnotesize Wait\\ \qty{24}{\hour}}; \path [line] (init) -- (wait1); \node [block, right of=wait1, node distance=3cm] (feed) {\footnotesize \qty{10}{\gram} of previous day + \qty{50}{\gram} water + \qty{50}{\gram} flour, stir}; \path [line] (wait1) -- (feed); @@ -8,7 +8,7 @@ \path [line] (feed) -- (discard); \node [decision, right of=feed, node distance=3.5cm] (decide) {\footnotesize Is good?}; \node [decision, above of=decide, node distance=3cm] (timeout) {\footnotesize Less than 10 feeds?}; - \node [block, above of=feed, node distance=3cm] (wait2) {\footnotesize Wait \qty{24}{\hour}}; + \node [block, above of=feed, node distance=3cm] (wait2) {\footnotesize Wait\\ \qty{24}{\hour}}; \node [fail, right of=timeout, node distance=3cm] (discard2) {\footnotesize Batch failed}; \path [line] (timeout) -- node{no} (discard2); \path [line] (timeout) -- node{yes} (wait2); diff --git a/book/figures/fig-starter-readiness.tex b/book/figures/fig-starter-readiness.tex index 8827e0c..6ed86a2 100644 --- a/book/figures/fig-starter-readiness.tex +++ b/book/figures/fig-starter-readiness.tex @@ -2,11 +2,11 @@ \node [start] (init) {\footnotesize Make a starter}; \node [block, right of=init, node distance=3cm] (feed) {\footnotesize Feed your starter}; \path [line] (init) -- (feed); - \node [block, right of=feed, node distance=3cm] (wait_12_after_feed) {\footnotesize Wait \qty{12}{\hour}}; + \node [block, right of=feed, node distance=3cm] (wait_12_after_feed) {\footnotesize Wait\\ \qty{12}{\hour}}; \path [line] (feed) -- (wait_12_after_feed); \node [block, right of=wait_12_after_feed, node distance=3cm] (ready_question) {\footnotesize Perform readiness check}; \path [line] (wait_12_after_feed) -- (ready_question); - \node [block, below of=feed, node distance=3cm] (wait_12) {\footnotesize Wait \qty{12}{\hour}}; + \node [block, below of=feed, node distance=4cm] (wait_12) {\footnotesize Wait\\ \qty{12}{\hour}}; \path [line] (wait_12) -- (feed); \node [decision, right of=ready_question, node distance=3.5cm] (is_bubbly) {\footnotesize Bubbly? Size Increase?}; \path [line] (ready_question) -- (is_bubbly); diff --git a/book/figures/fig-stiff-starter-conversion.tex b/book/figures/fig-stiff-starter-conversion.tex index 32b36ed..e41ab69 100644 --- a/book/figures/fig-stiff-starter-conversion.tex +++ b/book/figures/fig-stiff-starter-conversion.tex @@ -1,11 +1,11 @@ \begin{tikzpicture}[node distance = 3cm, auto] \node [start] (init) {\footnotesize Make a regular or liquid starter}; \node [block, right of=init] (feed_new_ratio) {\footnotesize Mix \qty{10}{\gram} existing starter, \qty{50}{\gram} flour and \qty{25}{\gram} water}; - \node [decision, right of=feed_new_ratio, node distance=3cm] (too_dry) {\footnotesize Starter very dry, hard to mix?}; + \node [decision, right of=feed_new_ratio, node distance=3.5cm] (too_dry) {\footnotesize Starter very dry, hard to mix?}; \node [block, right of=too_dry, node distance=4cm] (add_water) {\footnotesize Add more water}; - \node [block, below of=add_water, node distance=2cm] (next_day) {\footnotesize Wait \qty{24}{\hour}}; - \node [decision, below of=too_dry, node distance=3cm] (repeated_3_times) {\footnotesize Stiff starter fed 3 times overall?}; - \node [block, left of=repeated_3_times] (feed_again) {\footnotesize Feed again using 1:5:2.5 ratio}; + \node [block, below of=add_water, node distance=2cm] (next_day) {\footnotesize Wait\\ \qty{24}{\hour}}; + \node [decision, below of=too_dry, node distance=3.5cm] (repeated_3_times) {\footnotesize Stiff starter fed 3 times overall?}; + \node [block, below of=feed_new_ratio, node distance=3.5cm] (feed_again) {\footnotesize Feed again using 1:5:2.5 ratio}; \node [decision, below of=repeated_3_times, node distance=3.5cm] (ready_signs) {\footnotesize Size increase and sour smell?}; \node [block, below of=next_day, node distance=2cm] (last_feed) {\footnotesize Feed one last time}; \node [success, below of=last_feed, node distance=3cm] (bread_dough) {\footnotesize Make bread dough}; diff --git a/book/figures/flowcharts_tikz.tex b/book/figures/flowcharts_tikz.tex new file mode 100644 index 0000000..e4f8b7c --- /dev/null +++ b/book/figures/flowcharts_tikz.tex @@ -0,0 +1,21 @@ +\tikzstyle{every picture}+=[font=\small\sffamily] +\usetikzlibrary{shapes,arrows} +\tikzstyle{decision} = [diamond, draw=codeblack, fill=codeblack, text=white, + text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt, + line width=2mm] +\tikzstyle{block} = [rectangle, draw=codeblack, fill=white, text=black, + text width=5em, text centered, rounded corners, minimum height=4em, + line width=0.4mm] +\tikzstyle{decision_start} = [diamond, draw=codeblack, fill=pinkpic, text=black, + text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt, + line width=0.4mm] +\tikzstyle{start} = [rectangle, draw=codeblack, fill=pinkpic, text=black, + text width=5em, text centered, rounded corners, minimum height=4em, + line width=0.4mm] +\tikzstyle{success} = [rectangle, draw=codeblack, fill=yellowpic, text=black, + text width=5em, text centered, rounded corners, minimum height=4em, + line width=0.4mm] +\tikzstyle{fail} = [rectangle, draw=codeblack, fill=redpic, text=black, + text width=5em, text centered, rounded corners, minimum height=4em, + line width=0.4mm] +\tikzstyle{line} = [draw, -latex', thick, ->,>=to] diff --git a/book/figures/vars.tex b/book/figures/vars.tex index 465d558..b4bc120 100644 --- a/book/figures/vars.tex +++ b/book/figures/vars.tex @@ -1,13 +1,6 @@ \documentclass[tikz]{standalone} \usepackage{tikz} -\usepackage{siunitx} +\usepackage[mode=match, reset-text-family=false]{siunitx} \DeclareSIUnit\degF{\text{°}F} - -\definecolor{codeblue}{RGB}{69, 161, 248} -\definecolor{codegray}{RGB}{40, 40, 40} -\usetikzlibrary{shapes,arrows} -\tikzstyle{decision} = [diamond, draw, fill=codegray, text=white, - text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt] -\tikzstyle{block} = [rectangle, draw, fill=codeblue, text=white, - text width=5em, text centered, rounded corners, minimum height=4em] -\tikzstyle{line} = [draw, -latex'] +\input{flowcharts_tikz.tex} +\input{../colors.tex} diff --git a/book/makefile b/book/makefile index e08b164..3af2046 100644 --- a/book/makefile +++ b/book/makefile @@ -20,11 +20,11 @@ chapters = baking basics bread-types cover flour-types history intro\ wheat-sourdough src_tables := $(wildcard tables/table-*.tex) -src_figures := $(wildcard figures/fig-*.tex) +src_figures := $(wildcard figures/fig-*.tex) figures/flowcharts_tikz.tex src_tex := $(foreach directory, $(chapters), $(wildcard $(directory)/*.tex)) src_tex += book.tex book_sans_serif.tex references.bib figures/vars.tex -src_tex += supporters.csv sourdough.sty +src_tex += supporters.csv sourdough.sty colors.tex images := $(wildcard images/*/*.jpg) images += $(wildcard images/*/*.png) @@ -48,12 +48,13 @@ tgt_figures := $(patsubst %.tex, %.png,$(src_figures)) # TODO: check if it works on github CI %.png: %.tex - @echo "\input{./vars}" > $@.in + @echo "\input{./vars.tex}" > $@.in # \b is backspace.. @echo "\\\begin{document}" >> $@.in @cat $< >> $@.in - @echo "\end{document}" >> $@.in + @echo "\\\end{document}" >> $@.in $(LATEX) $@.in + figures/export_figures.sh $@.pdf %.xbb: %.jpg ebb -x $< @@ -167,6 +168,7 @@ clean_figures: - $(CLEAN) $(patsubst %.tex, %.png.in, $(src_figures)) - rm $(patsubst %.tex, %.png.pdf, $(src_figures)) - rm $(patsubst %.tex, %.png.in, $(src_figures)) + - rm $(wildcard figures/*.png.*) - rm cover/cover-page.xbb .PHONY: clean_ebook_build diff --git a/book/sourdough.sty b/book/sourdough.sty index 0e9a7e9..793b547 100644 --- a/book/sourdough.sty +++ b/book/sourdough.sty @@ -18,35 +18,10 @@ % For tables \renewcommand\theadfont{\bfseries} -\definecolor{codeblue}{RGB}{69, 161, 248} -\definecolor{codeblack}{RGB}{40, 40, 40} - -\definecolor{maingray}{HTML}{F8F8F8} - -\definecolor{hlocre}{HTML}{E5B874} -\definecolor{hlorange}{HTML}{EC7850} -\definecolor{hlyellow}{HTML}{FAE69E} - -\definecolor{pinkpic}{RGB}{246, 183, 194} -\definecolor{redpic}{RGB}{232, 72, 71} -\definecolor{yellowpic}{RGB}{246, 235, 51} - -\tikzstyle{every picture}+=[font=\small\sffamily] -\usetikzlibrary{shapes,arrows} -\tikzstyle{decision} = [diamond, draw, fill=codeblack, text=white, - text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt] -\tikzstyle{block} = [rectangle, draw, fill=codeblue, text=white, - text width=5em, text centered, rounded corners, minimum height=4em] -\tikzstyle{decision_start} = [diamond, draw, fill=pinkpic, text=black, - text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt] -\tikzstyle{start} = [rectangle, draw, fill=pinkpic, text=black, - text width=5em, text centered, rounded corners, minimum height=4em] -\tikzstyle{success} = [rectangle, draw, fill=yellowpic, text=black, - text width=5em, text centered, rounded corners, minimum height=4em] -\tikzstyle{fail} = [rectangle, draw, fill=redpic, text=black, - text width=5em, text centered, rounded corners, minimum height=4em] -\tikzstyle{line} = [draw, -latex'] - +\input{colors.tex} +% Define flowcharts macros independently so we can build them as png files +% for the website or something. This is supported in the makefile +\input{figures/flowcharts_tikz.tex} % Fonts \defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX} % Define Semi-bold @@ -58,7 +33,7 @@ \else \setmainfont{TeX Gyre Pagella}[Scale=1.0] % Or Palatino Linotype, etc. % TODO not available on github CI - % \setmonofont{Andale Mono}[Scale=MatchLowercase] + % \setmonofont{Andale Mono}[Scale=MatchLowercase] \fi % Opens Sans in both case.. \setsansfont{Open Sans}[