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}
defmypath{
(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}
tikz-pgf
add a comment |
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}
defmypath{
(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}
tikz-pgf
@ArtificialStupidity: Great idea, but how can I cache it? You have a funny name btw... :-)
– Dave
yesterday
1
two shapes is easy: simply usedraw[double,double distance=5pt].
– Ulrike Fischer
yesterday
For a general solution: tex.stackexchange.com/a/290609/2388.
– Ulrike Fischer
yesterday
... and for an even more general solution see tex.stackexchange.com/a/72753/121799 by the same author.
– marmot
yesterday
@ArtificialStupidity: Yes, I don't get it. Will post an update to my question in a few seconds...
– Dave
yesterday
add a comment |
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}
defmypath{
(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}
tikz-pgf
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}
defmypath{
(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}
tikz-pgf
tikz-pgf
edited 19 hours ago
Stefan Pinnow
19.7k83276
19.7k83276
asked yesterday
DaveDave
818616
818616
@ArtificialStupidity: Great idea, but how can I cache it? You have a funny name btw... :-)
– Dave
yesterday
1
two shapes is easy: simply usedraw[double,double distance=5pt].
– Ulrike Fischer
yesterday
For a general solution: tex.stackexchange.com/a/290609/2388.
– Ulrike Fischer
yesterday
... and for an even more general solution see tex.stackexchange.com/a/72753/121799 by the same author.
– marmot
yesterday
@ArtificialStupidity: Yes, I don't get it. Will post an update to my question in a few seconds...
– Dave
yesterday
add a comment |
@ArtificialStupidity: Great idea, but how can I cache it? You have a funny name btw... :-)
– Dave
yesterday
1
two shapes is easy: simply usedraw[double,double distance=5pt].
– Ulrike Fischer
yesterday
For a general solution: tex.stackexchange.com/a/290609/2388.
– Ulrike Fischer
yesterday
... and for an even more general solution see tex.stackexchange.com/a/72753/121799 by the same author.
– marmot
yesterday
@ArtificialStupidity: Yes, I don't get it. Will post an update to my question in a few seconds...
– Dave
yesterday
@ArtificialStupidity: Great idea, but how can I cache it? You have a funny name btw... :-)
– Dave
yesterday
@ArtificialStupidity: Great idea, but how can I cache it? You have a funny name btw... :-)
– Dave
yesterday
1
1
two shapes is easy: simply use
draw[double,double distance=5pt].– Ulrike Fischer
yesterday
two shapes is easy: simply use
draw[double,double distance=5pt].– Ulrike Fischer
yesterday
For a general solution: tex.stackexchange.com/a/290609/2388.
– Ulrike Fischer
yesterday
For a general solution: tex.stackexchange.com/a/290609/2388.
– Ulrike Fischer
yesterday
... and for an even more general solution see tex.stackexchange.com/a/72753/121799 by the same author.
– marmot
yesterday
... and for an even more general solution see tex.stackexchange.com/a/72753/121799 by the same author.
– marmot
yesterday
@ArtificialStupidity: Yes, I don't get it. Will post an update to my question in a few seconds...
– Dave
yesterday
@ArtificialStupidity: Yes, I don't get it. Will post an update to my question in a few seconds...
– Dave
yesterday
add a comment |
1 Answer
1
active
oldest
votes
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}
{ifnumX=0
xdefmypath{(X:2+rnd*0.9)}
else
xdefmypath{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}

1
Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no?
– Dave
yesterday
Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change...
– Dave
yesterday
1
@Dave Does addingpgfmathsetseed{12}(say) afterbegin{tikzpicture}solve this issue?
– marmot
yesterday
1
It solved it, thanks a lot!
– Dave
yesterday
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473181%2fhow-to-draw-irregular-shapes-inside-each-other%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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}
{ifnumX=0
xdefmypath{(X:2+rnd*0.9)}
else
xdefmypath{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}

1
Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no?
– Dave
yesterday
Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change...
– Dave
yesterday
1
@Dave Does addingpgfmathsetseed{12}(say) afterbegin{tikzpicture}solve this issue?
– marmot
yesterday
1
It solved it, thanks a lot!
– Dave
yesterday
add a comment |
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}
{ifnumX=0
xdefmypath{(X:2+rnd*0.9)}
else
xdefmypath{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}

1
Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no?
– Dave
yesterday
Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change...
– Dave
yesterday
1
@Dave Does addingpgfmathsetseed{12}(say) afterbegin{tikzpicture}solve this issue?
– marmot
yesterday
1
It solved it, thanks a lot!
– Dave
yesterday
add a comment |
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}
{ifnumX=0
xdefmypath{(X:2+rnd*0.9)}
else
xdefmypath{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}

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}
{ifnumX=0
xdefmypath{(X:2+rnd*0.9)}
else
xdefmypath{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}

edited yesterday
answered yesterday
marmotmarmot
97.2k4112214
97.2k4112214
1
Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no?
– Dave
yesterday
Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change...
– Dave
yesterday
1
@Dave Does addingpgfmathsetseed{12}(say) afterbegin{tikzpicture}solve this issue?
– marmot
yesterday
1
It solved it, thanks a lot!
– Dave
yesterday
add a comment |
1
Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no?
– Dave
yesterday
Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change...
– Dave
yesterday
1
@Dave Does addingpgfmathsetseed{12}(say) afterbegin{tikzpicture}solve this issue?
– marmot
yesterday
1
It solved it, thanks a lot!
– Dave
yesterday
1
1
Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no?
– Dave
yesterday
Thank you very much! I could not use Ulrike's answer because it is only valid for two shapes, no?
– Dave
yesterday
Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change...
– Dave
yesterday
Just one last question: How could I store the current image? All few minutes I recompile this formula my shape will change...
– Dave
yesterday
1
1
@Dave Does adding
pgfmathsetseed{12} (say) after begin{tikzpicture} solve this issue?– marmot
yesterday
@Dave Does adding
pgfmathsetseed{12} (say) after begin{tikzpicture} solve this issue?– marmot
yesterday
1
1
It solved it, thanks a lot!
– Dave
yesterday
It solved it, thanks a lot!
– Dave
yesterday
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473181%2fhow-to-draw-irregular-shapes-inside-each-other%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@ArtificialStupidity: Great idea, but how can I cache it? You have a funny name btw... :-)
– Dave
yesterday
1
two shapes is easy: simply use
draw[double,double distance=5pt].– Ulrike Fischer
yesterday
For a general solution: tex.stackexchange.com/a/290609/2388.
– Ulrike Fischer
yesterday
... and for an even more general solution see tex.stackexchange.com/a/72753/121799 by the same author.
– marmot
yesterday
@ArtificialStupidity: Yes, I don't get it. Will post an update to my question in a few seconds...
– Dave
yesterday