Home > tikz pgf > Decorating (with random steps) a filling pattern

# Decorating (with random steps) a filling pattern

January 23Hits:3
\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}

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:

Tags:tikz pgf

## Related Articles

• ### Decorating (with random steps) a filling patternJanuary 23

\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} --------------Solutions------------- You can declare new pat

• ### TikZ: decoration - random steps: how to get twice exactly the same shape?September 7

I'm creating a beamer presentation, in which I use TikZ. I am making a figure, on which I would like to highlight something (using \only<> command). My figure contains an ellipse that is decorated with random steps: ... \node[ellipse,minimum width=1

• ### Persistent random steps decorations during beamer \uncoverMarch 16

I'm using a random steps decoration with a path that appears through several uncover transitions. Currently the decoration is redrawn in each instance of the slide. How can I change this behavior. A minimal example follows. Thanks. \documentclass[pre

• ### How to correctly decorate an ellipse with random stepsDecember 14

To create something that looks like the shape of a lake, the following code transforms the border of a blue ellipse with smooth random steps. The idea is taken from another answer. \documentclass[tikz]{standalone} \usetikzlibrary{decorations.pathmorp

• ### Custom and built in TikZ fill patternsMay 4

I can't find much information about creating TikZ fill patterns or even using the custom built-in patterns. Look to do all the common fills like lines, hatches, dots, stars, etc... I need to be able to control the scale, too. (The patterns I did end

• ### inkscape problems exporting filling pattern to pdfMarch 31

I have created a filling pattern. When I export to pdf a shape filled with such pattern I get something really different from what I see in the editor. This is an example: what I see: what I get: Am I doing something wrong? thanks for your help -----

• ### Illustrator Basic fill patterns June 30

Where are the simple fill patterns such as diagonal parallel lines or regular texture. Adobe CS5 Mac OS X 10.10.3 27"iMac --------------Solutions------------- Adobe Illustrator CS5 > Presets > [your language] > Swatches > Patterns Open th

• ### Fill pattern for time series with bounds (tikz pgfplots) generates corrupt PDFOctober 26

I have used the answer from another post, but the generated PDF seems to be corrupted using the suggested code. This post refers to question: Fill pattern for time series with bounds (tikz pgfplots) An answer suggested using the following code: \docu

• ### Are there any geology fill pattern libraries for QGIS?October 15

I'm making a geologic map using QGIS but I don't know how to draw a limestone lithology in QGIS. To draw other lithologies I combine lines and dots in the best possible way but is very limited. Any suggestion? libraries? --------------Solutions------

• ### Rotate the fill pattern with the shape in tikz July 30

One of the problems with patterns is that you never know how individual tiles are going to be laid over the area. E.g. if you use star pattern, sometimes stars on the left side of the area shall be broken in half, and sometimes they shall be whole. I

• ### Leaflet Polyline with custom fill patternMarch 22

I'm drawing Lines with leaflet.js an have to create custom styled polylines. So i got various image files which should be like a repeated background image in HTML. So is it possible to give a drawn L.polyline a Custom background image (texture)? I kn

• ### PC randomly freezes with weird patterns / artifacts on screenAugust 11

I just got a new PC (which I assembled myself) having a Core i5 4670K and a Gigabyte Z97MX-Gaming 5 motherboard. I use the Intel HD graphic 4600 as the GPU. I am experiencing weird PC freezes which occur randomly (nothing to do with CPU/GPU load) whe

• ### How to turn off caching of fill patterns in TileMill?September 26

I'm using CartoCSS in TileMill and png files on disk for filling polygon symbols with patterns. polygon-pattern-file: url('sprites/yard.png'); The display is ok the first time, but when I change the file itself in a raster editor, polygon fills don't

• ### Fill pattern for time series with bounds (tikz pgfplots)October 2

I would like to plot three time series; two of them have bounds. In fact, it looks similar to the figure shown here: plotting two time series with bounds In my case, the two areas of the two time series with bounds overlap quite a bit, so the resulti

• ### illustrator - fill pattern does not translate with bounding boxJanuary 26

I have an EPS file of an imshow() plot that I generated from MATLAB using https://github.com/altmany/export_fig I didn't have this problem before, but now when I open the heatmap plot in illustrator and attempt to move the plot around, the colors shi

• ### Leaflet fill patternsApril 21

I am using the leaflet.pattern library at https://github.com/teastman/Leaflet.pattern and I want to change the color of my stripes based on a value in the feature just like I do in the following using a getColor Function as part of the style. functio

• ### TikZ custom zigzag patternMarch 24

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, patter

• ### Simulating hand-drawn linesDecember 25

I am working on a project that will have some vector graphics, perhaps using TikZ (or a similar package). All of the graphics consists of lines, in shades of gray. However, the lines from TikZ appear too clean. Is there any way to make the lines appe

• ### Glitch in 'Cool text highlighting'January 2

This answer provides a fantastic "ragged text highlight". Unfortunately I'm getting a weird glitch with it: I have literally taken the source code from the link and replaced the material between \begin{document} and \end{document} with {replacin

• ### TikZ/pgfplots: how can I generate a figure like this one?April 22

What's the easiest way to produce a figure like this one? The curve is meant to look wiggly and random, and always non-increasing, except for the jumps up. I have tried using decorations with random steps, but that doesn't look right and is sometimes