I'm trying to create a custom pattern made of zigzag lines. Thanks to the TikZ manual and to Decorating (with random steps) a filling pattern I'm almost there:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, patterns,shapes}
\begin{document}
\pgfdeclarepatternformonly{zigzag}
{\pgfpointorigin}{\pgfpoint{1cm}{1cm}}
{\pgfpoint{0.3cm}{0.3cm}}
{
\tikz\draw[decoration = {zigzag,segment length = 2mm, amplitude = 2mm}, decorate] (0,0) -- ++(3,0);
}
\begin{tikzpicture}
\node[draw=black,pattern=zigzag,regular polygon,regular polygon sides=5,minimum size=10mm] at (0,0.5){};
\end{tikzpicture}
\end{document}
The above code produces this:
But what I'd like is something like this:
I'd like the zigzag line to be more "relaxed". I've messed up with the \pgfdeclarepatternformonly
parameters but I'm not able to obtain the zigzag line I like.
Also, I don't understand what the purpose of ++
is in (0,0) -- ++(3,0)
.
More Details
the zigzag line I want is produced by this code
\draw[decoration = {zigzag,segment length = 3mm, amplitude = 1mm},decorate] (0,0)--(1,0);
but it doesn't work as expected. When inserted in the previous code it prodces this:
Solved (but I still don't understand why)
So, I solved my problem by trials and errors. The code that produces the pattern I want is this:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, patterns,shapes}
\begin{document}
\pgfdeclarepatternformonly{zigzag}
{\pgfpointorigin}{\pgfpoint{2cm}{2cm}}{\pgfpoint{0.35cm}{0.15cm}}
{
\tikz\draw[decoration = {zigzag,segment length = 0.35cm, amplitude = 0.9mm},decorate,very thin] (0,1.5) -- (2.9,1.5);
}
\begin{tikzpicture}
\node[draw=black,pattern=zigzag,regular polygon,regular polygon sides=5,minimum size=10mm] at (0,0){};
\end{tikzpicture}
\end{document}
Unfortunately I still have a vague undestanding of what I did, so I'll accept as correct answer that which will explain why this code works.
\pgfdeclarepatternformonly
parameters to obtain the zigzag line I want. If you change thepgfpoint
,segment lenght
andamplitude
values you'll get different zigzag lines. Problem is I don't understand how they interact with each other so I can't get what I want.