Am 13.03.2012 15:45, schrieb Thomas A. Schmitz:
> Hi all,
> 
> scenario: for a presentation, I want the background to be a random
> picture, taken from a directory "backgroundpics." The pictures are
> numbered consecutively as 1.jpg through 22.jpg. For some complex
> reasons, it would be easier for me to include these pictures via metafun
> (I want to add other graphical elements on top). So my question is, how
> can I pick a random picture? Given the code
> 
> StartPage ;
>   draw externalfigure "backgoundpics/1" xscaled PaperWidth yscaled
> PaperHeight ;
> StopPage ;
> 
> how can I obtain a random number and make metapost pick the
> corresponding picture? Sorry, difficult to make a minimal example here...
>
(slightly tested)

string mypath, rndfile;

mypath:= "backgroundpics/";
nofpics:= 22;

n:= round(uniformdeviate(nofpics-1)+1);
rndfile:= mypath & decimal n;


HTH,  Peter


> Thomas
> ___________________________________________________________________________________
> 
> If your question is of interest to others as well, please add an entry
> to the Wiki!
> 
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 
> 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to