[pstricks] psRandom (PSTricks-add command) and Beamer overlays
Christoph Bersch
usenet at bersch.net
Wed Sep 19 15:20:14 CEST 2012
Am 19.09.2012 13:09, schrieb Christian Häger:
>
> consider the following minimal example, where the \psRandom command
> is used to draw random points on a slide, together with an overlay.
>
> The effect is that on the second slide, where the overlay appears,
> the random points are changing.
A rather small change in the \psRandom at iii definition would allow to set
a fixed seed or not (with a new parameter randomSeed).
randomSeed=0 retains the current behaviour, using any other integer
fixes the seed:
\documentclass{beamer}
\usepackage{pstricks-add}
\makeatletter
\define at key[psset]{pstricks-add}{randomSeed}[0]{\pst at checknum{#1}\psk at randomSeed}
\psset[pstricks-add]{randomSeed=0}
\def\psRandom at iii(#1)(#2)#3{%
\def\pst at tempA{#3}%
\ifx\pst at tempA\pst at empty\psclip{\psframe(#2)}\else\psclip{#3}\fi
\pst at getcoor{#1}\pst at tempA
\pst at getcoor{#2}\pst at tempB
\begin at SpecialObj
\addto at pscode{
\pst at tempA\space /yMin exch def
/xMin exch def
\pst at tempB\space /yMax exch def
/xMax exch def
/dy yMax yMin sub def
/dx xMax xMin sub def
% changed the following line
\psk at randomSeed\space cvi dup 0 eq { pop rrand } if srand
/getRandReal { rand 2147483647 div } def
\psk at dotsize % defines /DS ... def
\@nameuse{psds@\psk at dotstyle}
\psk at randomPoints {
\ifPst at color getRandReal getRandReal getRandReal setrgbcolor \fi
getRandReal dx mul xMin add
getRandReal dy mul yMin add
Dot
\ifx\psk at fillstyle\psfs at solid fill \fi stroke
} repeat
}%
\end at SpecialObj
\endpsclip
\ignorespaces
}
\makeatother
\begin{document}
\begin{frame}\frametitle{old behaviour}
\begin{pspicture}(5,5)
\psRandom[randomPoints=100](0,0)(5,5)%
{\pscircle(2.5,2.5){2.5}}
\end{pspicture}
\uncover<2>{I am an overlay}
\end{frame}
\begin{frame}\frametitle{fixed seed}
\begin{pspicture}(5,5)
\psRandom[randomPoints=100, randomSeed=1](0,0)(5,5)%
{\pscircle(2.5,2.5){2.5}}
\end{pspicture}
\uncover<2>{I am an overlay}
\end{frame}
\end{document}
Christoph
More information about the PSTricks
mailing list