[pstricks] psRandom (PSTricks-add command) and Beamer overlays

Alexander Grahn A.Grahn at hzdr.de
Wed Sep 19 14:50:18 CEST 2012

On Wed, Sep 19, 2012 at 01:09:16PM +0200, Christian Häger wrote:
>consider the following minimal example, where the \psRandom command is used to draw random points on a slide, together with an overlay. 
>	\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}
>The effect is that on the second slide, where the overlay appears, the random points are changing. I assume that this is because beamer automatically copies the \psRandom command on each overlay-slide and therefore draws new random points on every slide. Is there a possibility to have the same random points appear on every slide? I don't know how the \psRandom command works but maybe it uses some input seed for a random number generator which could be frozen for the slide? 

You are right, the Postscript code for calculating the random dots is
copied on every slide. The calculation itself is deferred to the ps2pdf
conversion step or to visualisation time and executed (once per page) by
the Postscript interpreter. Therefore you get different sets of random dots.

Fortunately, one can distill the graphics once into a PDF Form-XObject
and replay it deliberately often without re-executing the Postscript
code. This is, e. g., implemented in the media9 LaTeX package. Making use
of one of the macros defined therein, I came up with the following
solution (Replaying the Form XObject is done using the /SP pdfmark): 




	\special{ps: mark \lastxform /SP pdfmark }
  \uncover<2>{I am an overlay}


More information about the PSTricks mailing list