# How to draw irregular shapes inside each other?

Let's assume we have this irregular shaped object:

Minimum Working Example (MWE):

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
\draw plot[domain=0:350, smooth cycle] (\x:2+rnd*0.9);
\end{tikzpicture}
\end{document}


Screenshot of the result:

Description of the issue:

How can I draw the exactly same shape around the initial one, but with a bigger radius to create some "skin" like layer around the first one?

In fact I need two more shapes of those, each of them with a bigger radius than the previous one. Furthermore, the shapes should have some fill (either color or better: Dots).

Background:

I want to visualize a soil particle where a biofilm is growing on the surface of the particle. In the end it could look like part of the following image, but in my case where the biofilm is growing around the whole particle:

In best case, we could add some arrow on the right side to visualize the streaming gas... :-)

Update (2019/02/03):

This approach inspired by an answer of "Surrounding an arbitrary path?" based on the definition of mypath is throwing errors:

\documentclass[tikz,border=3cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{%
draw seam allowance/.style 2 args={
preaction={line width=1mm,line join=round,double distance=#1*2,draw=#2},
},
seam allowances/.style={%
preaction={clip},
preaction={draw seam allowance/.list={#1}},
draw,%fill=white,
},
seam allowances/.default={{{2cm}{blue}}},
invclip/.style={
clip,
insert path={
{[reset cm] (-16000pt,-16000pt)  -| (16000pt,16000pt) -| cycle}
},
},
}
\begin{document}
\begin{tikzpicture}
\def\mypath{
(\x:2+rnd*0.9) -- cycle
}
\begin{scope}
\begin{pgfinterruptboundingbox}
\path [invclip] \mypath;
\end{pgfinterruptboundingbox}
\draw [seam allowances={{4cm}{black},{2cm}{black}},line width=2mm]
\mypath ;
\end{scope}
\end{tikzpicture}
\end{document}

• @ArtificialStupidity: Great idea, but how can I cache it? You have a funny name btw... :-) – Dave Feb 3 '19 at 15:24
• two shapes is easy: simply use \draw[double,double distance=5pt]. – Ulrike Fischer Feb 3 '19 at 15:41
• For a general solution: tex.stackexchange.com/a/290609/2388. – Ulrike Fischer Feb 3 '19 at 15:43
• ... and for an even more general solution see tex.stackexchange.com/a/72753/121799 by the same author. – user121799 Feb 3 '19 at 15:46
• @ArtificialStupidity: Yes, I don't get it. Will post an update to my question in a few seconds... – Dave Feb 3 '19 at 16:36

## 1 Answer

The problem with your code is that \mypath is not a proper path. This is a proposal to fix this (presumably based on this answer). We build up a list of random coordinates and then use them in the path.

\documentclass[tikz,border=3cm]{standalone}
\tikzset{%
draw seam allowance/.style 2 args={
preaction={line width=1mm,line join=round,double distance=#1*2,draw=#2},
},
seam allowances/.style={%
preaction={clip},
preaction={draw seam allowance/.list={#1}},
draw,%fill=white,
},
seam allowances/.default={{{2cm}{blue}}},
invclip/.style={
clip,
insert path={
{[reset cm] (-16000pt,-16000pt)  -| (16000pt,16000pt) -| cycle}
},
},
}
\begin{document}
\begin{tikzpicture}
\pgfmathsetseed{12}
\foreach \X in {0,20,...,340}
{\ifnum\X=0
\xdef\mypath{(\X:2+rnd*0.9)}
\else
\xdef\mypath{\mypath (\X:2+rnd*0.9)}
\fi
}
\begin{scope}
\begin{pgfinterruptboundingbox}
\path [invclip] \mypath;
\end{pgfinterruptboundingbox}
\draw [seam allowances={{4cm}{black},{2cm}{black}},line width=2mm]
plot[smooth cycle] coordinates {\mypath };
\end{scope}
\end{tikzpicture}
\end{document}


• Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no? – Dave Feb 3 '19 at 19:37
• Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change... – Dave Feb 3 '19 at 19:54
• @Dave Does adding \pgfmathsetseed{12} (say) after \begin{tikzpicture} solve this issue? – user121799 Feb 3 '19 at 19:58