7

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

Output

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.

Thanks in advance.

  • Is there any constraints on smoothness of the resulting shape path? And are you happy with your result above? – percusse Aug 28 '13 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 '13 at 21:13
  • 1
    Related Random ink blotches from tikz – texenthusiast Aug 29 '13 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 '13 at 18:39
4

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[2]{
 \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. enter image description here

  • 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 '13 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.