# Creating random patterns in TikZ

I'm interested in doing two (not completely) separate things in TikZ, if I should open another question for one part, please tell me so.

What I'm interested in is:

1. Create a random array of filled shapes.
2. Create a random shape.

and maybe combine the two, but that will be the next step. what I want is to define the shape limit (like 10pt, 20pt etc.) and not to determine it's path.

EDIT:

Here's what I got so far (can't answer my own question yet) , for instance:

\begin{tikzpicture}
\def\x{rnd*4}
\foreach \i in {4,8,...,16} {
\edef\x{\x*rnd+\i}
\draw [fill=black,
decoration={random steps,segment length=.5cm,amplitude=.5cm},
decorate,
rounded corners=.3cm]
(\x,\x) -- (\x+3,\x) -- (\x+3,\x+3) -- (\x,\x+3) -- (\x,\x);
}
\end{tikzpicture}


will result in As you can see it's not really random but "ascending".

So, to narrow it down :

I would like the patterns to sit on random (or seemingly random) places, without intersecting each other.

• Is there any constraints on smoothness of the resulting shape path? And are you happy with your result above? Aug 28, 2013 at 20:23
• no constraints, actually I got really close to what I wanted, so I'm going to edit the question.
– Bitx
Aug 28, 2013 at 21:13
• Aug 29, 2013 at 4:10
• I think the related question is going to help me indeed. Man, I have to start using the search better :/
– Bitx
Aug 29, 2013 at 18:39

Since no constraints on smoothness of the result, I use pentagon for illustrations where I defined a macro (called \irregularshape) to draw a pentagon, whose vertices are determined randomly.

 \documentclass[]{standalone}
\usepackage{tikz}

\begin{document}
\newcommand\irregularshape{
\begin{tikzpicture}
\tikzstyle{every node}=[coordinate]
\foreach \t/\x/\y in {1/18/1, 2/90/1.2, 3/162/1.4, 4/234/1.2, 5/306/1}
{\pgfmathsetmacro\lenx{rnd*#1}   % seed
\pgfmathsetmacro\leny{rnd*#2}    % seed
\node(\t) at (\x+\lenx:\y+\leny) {};}
\foreach \from/\to in {1/2, 2/3, 3/4, 4/5, 5/1}
{\draw [fill=black,rounded corners=1mm] (\from) -- (\to);}
\end{tikzpicture}
}

%Parameters (#1,#2) are changeable, yielding vertices

\begin{tabular}{cc}
\irregularshape{0.8}{1}&\irregularshape{1}{.2}\\
\irregularshape{1.4}{.3}&\irregularshape{.3}{2} \\
\irregularshape{.3}{.4}&\irregularshape{2}{.3} \\
\end{tabular}
\end{document}


and an image is included. • That's not really what I meant (the places of the shape has an orderly fashion about it), but I'm going to upvote it anyway because it gave me some insight for what I'm working on.
– Bitx
Aug 29, 2013 at 18:37