![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 7/12/2021 5:31 AM, Aditya Mahajan wrote:
On Sun, 11 Jul 2021, Bruce Horrocks wrote:
On 9 Jul 2021, at 17:29, Hans Hagen
wrote: This weekend upload has something new for metapost animation lovers:
Forgive my ignorance but what exactly am I supposed to be seeing here? I run the example and get two rows of ten boxes. They don't move so it's not like an animated GIF was put into the PDF and they don't appear to be consecutive frames that could be joined into an animated GIF.
For me, this feature provides the same capability as 'layers' in a graphical program. Consider the diagram shown in page 1 of the attached PDF. Suppose I want to "highlight" boxes A and B by drawing a square around them. That is easy; simply determine the bounding box of A, B (I do that manually here), and expand it a bit and draw it. Simple. See page 2.
Now, suppose I want to fill this highlighted box. Suddenly, we have a problem. The highlight box needs to be "behind" the other boxes. How do we do it. We determine the location of boxes A, B, and C, but do not draw them. Determine the highlight box. Now draw the highlight box first and then draw the boxes. Suddenly the code became an order of magnitude more complicated.
With the new stacking mechanism, I can just put the highlight box on "stack -1", and everything works well. See page 4. What's also super cool is that I can control what gets shown by changing the stacking key.
Let's assume that the last MPpage was a \startuseMPgraphic{boxes} .... \stopuseMPgraphic. Suppose I wanted to use these pictures in a presentation. On the first slide, I can use
\useMPgraphic[stacking=0]{boxes}
to show the three boxes, and on the next slide, I can use
\useMPgraphic[stacking={-1,0}]{boxes}
to show the boxes and the highlight. Drawing such "conditional" graphics was cumbersome in the past. Now, it is easier.
If you show a bunch of such "conditional" graphics in a sequence, you get an animation (or you could wrap around the animation module).
Aditya
PS: Hans, stacking doesn't completely work with the boxes macro. drawunboxed is always drawn on stack 0, which the bpath is drawn on the right stack. That is the reason I use stack = -1 to put the highlight in the "background".
in a netx upload this will work ok \startMPpage[offset=2mm, stacking={1,2}] draw fullsquare scaled 4cm withstacking 2 withcolor "red" ; draw image ( draw fullsquare scaled 2cm withstacking 3 withcolor "green" withstacking 3 ; draw fullsquare scaled 1cm withstacking 4 withcolor "blue" withstacking 4 ; ) withstacking 2 withcolor "cyan"; drawarrow llcorner currentpicture .. origin withstacking 3; \stopMPpage ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------