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 <j.ha...@xs4all.nl> 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".
I need to ckeck if the range checked does negative numbers ... anyway,
you can do this
\startMPpage[offset=2mm, stacking={1,2,3,4}]
boxit.A("\boxframed{Box A}");
boxit.B("\boxframed{Box B}");
boxit.C("\boxframed{Box C}");
defaultdx := 0pt;
defaultdy := 0pt;
A.c = origin;
B.w - A.e = (1cm, 0);
0.5[ A.s, B.s ] - C.n = (0, 1cm);
draw image (drawunboxed(A,B,C)) withstacking 2;
drawarrow A.s +- C.w withstacking 3 ;
drawarrow B.s +- C.e withstacking 4 ;
newpath highlight;
highlight := (A.sw -- B.se -- B.ne -- A.nw) enlarged EmWidth;
fill highlight withcolor "darkgray" withstacking 1;
\stopMPpage
but only the first edge in an image picture is adapted ... (i actually
know that i need to fix that in mplib because i noticed the same issue
with color etc (some old issue)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________