2

The followin code gives this error :

! Argument of \pgfmathrnd@@ has an extra }.
<inserted text> 
                \par 
l.12    }

? 
! Emergency stop.
<inserted text> 
                \par 
l.12    }

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on bob.log.

Done.

What is wrong ?

\documentclass[tikz]{standalone}
\usetikzlibrary{patterns}

\pgfdeclarepatternformonly{Rnd}
{\pgfpointorigin}{\pgfpoint{.5cm}{.5cm}}
{\pgfpoint{1cm}{1cm}}
{
    \pgfpathcircle{%
        %\pgfpoint{.25cm}{.25cm}}{.4pt}
        \pgfpoint{\pgfmathrnd*.25cm}{\pgfmathrnd*.25cm}}{.4pt}
    \pgfusepath{fill}
}

\begin{document}
\begin{tikzpicture}

\draw[pattern=Rnd] (0,0) rectangle (5,5) ;
\end{tikzpicture}

\end{document}
  • Section 97.2: \pgfpoint{<x coord>}{<y coord} Yields a point location. The coordinates are given as TeX dimensions. – egreg Jun 15 '14 at 17:59
  • I don't understand what it means. By the way, I have no 97.2 section in my pfg 3.00 manual. Witch is the page, please ? – Tarass Jun 15 '14 at 18:07
  • You should use the function directly, see my answer in Fill style that looks like hand-drawn / hand-filled with crayon for instance. – Claudio Fiandrino Jun 15 '14 at 18:12
  • @ClaudioFiandrino An answer? – egreg Jan 24 '15 at 23:09
  • @egreg: It deserves one, indeed. I will answer later in the day. – Claudio Fiandrino Jan 25 '15 at 8:41
3

In this case it is not possible to use the macros \pgfmathrnd, \pgfmathrand or \pgfmathrandom otherwise the result is not in the appropriate form to be parsed. The correct way is to use directly the functions rnd, rand or random:

\pgfpoint{rnd*.25cm}{rnd*.25cm}}{.4pt}

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.