Am 31.12.2025 um 12:38 schrieb Keith McKay:
Hi all,

The following example creates a unitcircle scaled to the \recurselevel value on each MPpage.

\starttext
\dostepwiserecurse{1}{80}{1}{
\startMPpage
     path a;
     a := unitsquare xyscaled(80,80) ;
     draw a;
     draw unitcircle xyscaled(\recurselevel , \recurselevel);
\stopMPpage
}
\dostepwiserecurse{79}{2}{-1}{
\startMPpage
     path a;
     a := unitsquare xyscaled(80,80) ;
     draw a;
     draw unitcircle xyscaled(\recurselevel , \recurselevel);
\stopMPpage
}
\stoptext

If you run this and scan through pages, the circle starts at 1 and increases to 80 and then decreases from 79 to 2. I use the pdf to create a mp4 movie showing the circle increasing and decreasing when I replay it as a loop. You can download the file here:

https://1drv.ms/v/c/de5fffb8e01e255b/ IQCLuQ9bYQovSIaOc7S5vc8_AQnAfqudRCjr_PC_pT6Rgx8?e=fuq9AS

However if my graphic is complicated, compilation time will increase by quite a bit. So I was thinking that when the circle is decreasing I have already calculated those MPpages as the circle was increasing so could I not reuse those MPpages to create the following sequence of MPpages?

1, 2, 3, ... 78, 79, 80, 79, 78, ...3, 2

i.e I have reused the MPpages 79 to 2 which would loop in a movie when played back.


\startMPinitializations
picture Circle[];
\stopMPinitializations

\startbuffer
\startMPpage
if unknown Circle[\recurselevel] :
  Circle[\recurselevel] := image (
    draw unitsquare scaled 80 ;
    draw unitcircle scaled \recurselevel ;
  ) ;
fi ;
draw Circle[\recurselevel] ;
\stopMPpage
\stopbuffer

\starttext
\dostepwiserecurse{1}{80}{1}{\getbuffer}
\dostepwiserecurse{79}{2}{-1}{\getbuffer}
\stoptext

Wolfgang

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

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to