7
\fill[pattern=north east lines] (A,B) rectangle (C,D);

How to make so that the stripe the pattern creates is of style decoration = {random steps, segment length = 0.5mm, amplitude = 0.15pt}

Ilonpilaaja
  • 1,335

1 Answers1

8

You can declare new patterns. The TikZ manual discusses it in chapter 78.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, patterns}
\begin{document}
\pgfdeclarepatternformonly{mystripes}
{\pgfpointorigin}{\pgfpoint{1cm}{1cm}}
{\pgfpoint{1cm}{1cm}}
{
  \tikz\draw[decoration = {random steps, segment length = 0.5mm, amplitude = 0.15pt}, decorate] (0,0) -- ++(1,1);
}
\begin{tikzpicture}
  \filldraw[pattern=mystripes] (0,0)   rectangle (1.5,2);
\end{tikzpicture}
\end{document}

Play around with it a bit in order to get more lines, make it parameterized, etc.

A possible parameter might be the distance between two lines:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, patterns}
\begin{document}
\tikzset{mystripes dist/.initial=0.25}
\pgfdeclarepatternformonly[/tikz/mystripes dist]{mystripes}
{\pgfpointorigin}{\pgfpoint{1cm}{1cm}}
{\pgfpoint{1cm}{1cm}}
{
  \foreach \x in {0,\pgfkeysvalueof{/tikz/mystripes dist},...,1}{
    \pgfmathsetmacro{\nx}{1-\x}
    \tikz[overlay]\draw[decoration = {random steps, segment length = 0.5mm, amplitude = 0.15pt}, decorate] (\x, 0) -- ++(\nx,\nx);
    \tikz[overlay]\draw[decoration = {random steps, segment length = 0.5mm, amplitude = 0.15pt}, decorate] (0, \x) -- ++(\nx,\nx);
  }
}
\begin{tikzpicture}
  \filldraw[pattern=mystripes] (0,0)   rectangle (1.5,2);
  \filldraw[pattern=mystripes, xshift=2cm, mystripes dist=0.1] (0,0) rectangle (1.5,2);
\end{tikzpicture}
\end{document}

The result then looks like this:

TikZ patterns

Roelof Spijker
  • 17,663
  • 5
  • 55
  • 63
  • Ok, so we are delving into the pgf level. Ch.78 of the manual talks about keys, registers and macros. Thanks guys, I'll accept one of the two after I figure out the thing following your suggestions. My (implicit) question was whether it is possible to supply "randomsteps" as an argument to "pattern". Seems not. – Ilonpilaaja Jan 23 '12 at 14:56