Re: [NTG-context] weekend upload - stacking and animation

2021-07-13 Thread Jeong Dal
Dear Hans, Wolfgang,

Both of your methods are working well.

Using \frame, the \dorecurse problem is solved.

\starttext
\startanimation[menu=yes]
 \dorecurse{10}
  { \frame{\useMPgraphic[stacking={#1}]{demo}}}
\stopanimation
\stoptext

Thank you for your solutions.

Best regards,

Dalyoung

___
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
___


Re: [NTG-context] weekend upload - stacking and animation

2021-07-13 Thread Hans Hagen

On 7/13/2021 4:11 PM, Floris van Manen wrote:



On 13/07/2021 15:14, Hans Hagen wrote:

How about:

\startuseMPgraphic{demo}
 for i=1 upto 10:
 draw fullcircle scaled (i*cm/3)
 withcolor (i*red/10)
 withpen   pencircle scaled (bp/2)
 withstacking i
 ;
 endfor ;
\stopuseMPgraphic

\unprotect

\tolerant\protected\def\useMPanimation[#1]#2%
   {\begingroup
    \scratchtoks\emptytoks

\dorecurse{10}{\etoksapp\scratchtoks{{\useMPgraphic[\c!stacking={\recurselevel}]{#2% 


    \expanded{\startanimation[#1]\the\scratchtoks\stopanimation}%
    \endgroup}

\protect

\setupinteraction[state=start]

\usemodule[animation]

\starttext
 \useMPanimation[menu=yes]{demo}
\stoptext


Placing this excerpt in a file and compiling it I get an error:


you probably don't have the animation module installed


-
  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
___


Re: [NTG-context] weekend upload - stacking and animation

2021-07-13 Thread Wolfgang Schuster

Jeong Dal schrieb am 13.07.2021 um 12:25:

Dear Hans, Aditya,

Now, I understand the stacking method.
I made a simple animation using it.

\startuseMPgraphic{demo}
for i=1 upto 10:
draw fullcircle scaled (.3*i*cm) withcolor (.1*i*red) withpen 
pencircle scaled (.5*bp) withstacking i;

endfor;
\stopuseMPgraphic
\setupinteraction[state=start]
\usemodule[animation]
\starttext
\startanimation[menu=yes]
% \dorecurse{10}
% { {\useMPgraphic[stacking={#1}]{demo}}}
{\useMPgraphic[stacking={1}]{demo}}
{\useMPgraphic[stacking={2}]{demo}}
{\useMPgraphic[stacking={3}]{demo}}
{\useMPgraphic[stacking={4}]{demo}}
{\useMPgraphic[stacking={5}]{demo}}
{\useMPgraphic[stacking={6}]{demo}}
{\useMPgraphic[stacking={7}]{demo}}
{\useMPgraphic[stacking={8}]{demo}}
{\useMPgraphic[stacking={9}]{demo}}
{\useMPgraphic[stacking={10}]{demo}}
\stopanimation
\stoptext

However, I cannot succeed to use \dorecurse to make the code simple.
If there is another good method, please let me know.


\dorecurse {...} {\frame{...}}

Wolfgang

___
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
___


Re: [NTG-context] weekend upload

2021-07-13 Thread Jeong Dal
Dear Aditya,

> You cannot use [offset=2mm] here. Just use \startuseMPgraphic{boxes}.
> 

After remove [offset=smm], it is working well.

Thank you for the solution.

Best regards,

Dalyoung
___
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
___


Re: [NTG-context] weekend upload - stacking and animation

2021-07-13 Thread Jeong Dal
Dear Hans, Aditya,

Now, I understand the stacking method.
I made a simple animation using it.


\startuseMPgraphic{demo}
  for i=1 upto 10:
  draw fullcircle scaled (.3*i*cm)  withcolor (.1*i*red) withpen  pencircle 
scaled (.5*bp) withstacking i;
  endfor;
\stopuseMPgraphic
\setupinteraction[state=start]
\usemodule[animation]

\starttext
\startanimation[menu=yes]
%  \dorecurse{10}
%  { {\useMPgraphic[stacking={#1}]{demo}}}
  {\useMPgraphic[stacking={1}]{demo}}
  {\useMPgraphic[stacking={2}]{demo}}
  {\useMPgraphic[stacking={3}]{demo}}
  {\useMPgraphic[stacking={4}]{demo}}
  {\useMPgraphic[stacking={5}]{demo}}
  {\useMPgraphic[stacking={6}]{demo}}
  {\useMPgraphic[stacking={7}]{demo}}
  {\useMPgraphic[stacking={8}]{demo}}
  {\useMPgraphic[stacking={9}]{demo}}
  {\useMPgraphic[stacking={10}]{demo}}
\stopanimation
\stoptext


However, I cannot succeed to use \dorecurse to make the code simple.
If there is another good method, please let me know.

Anyway, thanks for this new feature!

Best regards,
Dalyoung___
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
___


Re: [NTG-context] weekend upload - stacking and animation

2021-07-13 Thread Floris van Manen



On 13/07/2021 15:14, Hans Hagen wrote:

How about:

\startuseMPgraphic{demo}
     for i=1 upto 10:
     draw fullcircle scaled (i*cm/3)
     withcolor (i*red/10)
     withpen   pencircle scaled (bp/2)
     withstacking i
     ;
     endfor ;
\stopuseMPgraphic

\unprotect

\tolerant\protected\def\useMPanimation[#1]#2%
   {\begingroup
    \scratchtoks\emptytoks

\dorecurse{10}{\etoksapp\scratchtoks{{\useMPgraphic[\c!stacking={\recurselevel}]{#2% 


    \expanded{\startanimation[#1]\the\scratchtoks\stopanimation}%
    \endgroup}

\protect

\setupinteraction[state=start]

\usemodule[animation]

\starttext
     \useMPanimation[menu=yes]{demo}
\stoptext


Placing this excerpt in a file and compiling it I get an error:


$ context animation.tex

resolvers   | formats | executing runner 'run luametatex format': 
/home/vm/context/tex/texmf-linux-64/bin/luametatex --jobname="animation" 
--fmt=/home/vm/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.fmt 
--lua=/home/vm/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.lui 
cont-yes.mkiv --c:currentrun=1 --c:fulljobname="./animation.tex" 
--c:input="./animation.tex" --c:kindofrun=1 --c:maxnofruns=9 
--c:texmfbinpath="/home/vm/context/tex/texmf-linux-64/bin"

open source > level 1, order 1, name 'cont-yes.mkiv'
fonts   > beware: no fonts are loaded yet, using 'lm mono' in box
system  >
system  > ConTeXt  ver: 2021.07.10 21:51 LMTX  fmt: 2021.7.12 
int: english/english

system  > system  > 'cont-new.mkxl' loaded
open source > level 2, order 2, name 
'/home/vm/context/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'

system  > beware: some patches loaded from cont-new.mkiv
close source> level 2, order 2, name 
'/home/vm/context/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system  > files > jobname './animation', input 
'./animation.tex', result './animation'

fonts   > latin modern fonts are not preloaded
languages   > language 'en' is active
open source > level 2, order 3, name './animation.tex'
modules > 'animation' is not found
fonts   > preloading latin modern fonts (second stage)
fonts   > 'fallback modern-designsize rm 12pt' is loaded
tex error   > tex error on line 31 in file ./animation.tex: 
Undefined control sequence


\startanimation [menu=yes]{\useMPgraphic 
[stacking={1}]{demo}}{\useMPgraphic [stacking={2}]{demo}}{\useMPgraphic 
[stacking={3}]{demo}}{\useMPgraphic [stacking={4}]{demo}}{\useMPgraphic 
[stacking={5}]{demo}}{\useMPgraphic [stacking={6}]{demo}}{\useMPgraphic 
[stacking={7}]{demo}}{\useMPgraphic [stacking={8}]{demo}}{\useMPgraphic 
[stacking={9}]{demo}}{\useMPgraphic [stacking={10}]{demo}}


 \startanimation [menu=yes]\the \scratchtoks \stopanimation

 \expanded #1->\xdef \m_syst_helpers_expanded {\noexpand #1
}\m_syst_helpers_expanded
 \useMPanimation [#1]#2->\begingroup \scratchtoks \emptytoks \par 
\dorecurse {10}{\etoksapp \scratchtoks {{\useMPgraphic [\c!stacking 
={\recurselevel }]{#2\expanded {\startanimation [#1]\the 
\scratchtoks \stopanimation }

\endgroup

 \useMPanimation[menu=yes]{demo}

21\expanded{\startanimation[#1]\the\scratchtoks\stopanimation}%
22\endgroup}
23
24 \protect
25
26 \setupinteraction[state=start]
27
28 \usemodule[animation]
29
30 \starttext
31 >>  \useMPanimation[menu=yes]{demo}
32 \stoptext
33
The control sequence at the end of the top line of your error message 
was never

\def'ed. You can just continue as I'll forget about whatever was undefined.
mtx-context | fatal error: return code: 256

___
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
___


Re: [NTG-context] weekend upload - stacking and animation

2021-07-13 Thread Hans Hagen

On 7/13/2021 12:25 PM, Jeong Dal wrote:

Dear Hans, Aditya,

Now, I understand the stacking method.
I made a simple animation using it.


\startuseMPgraphic{demo}
for i=1 upto 10:
draw fullcircle scaled (.3*i*cm) withcolor (.1*i*red) withpen pencircle 
scaled (.5*bp) withstacking i;

endfor;
\stopuseMPgraphic
\setupinteraction[state=start]
\usemodule[animation]

\starttext
\startanimation[menu=yes]
% \dorecurse{10}
% { {\useMPgraphic[stacking={#1}]{demo}}}
{\useMPgraphic[stacking={1}]{demo}}
{\useMPgraphic[stacking={2}]{demo}}
{\useMPgraphic[stacking={3}]{demo}}
{\useMPgraphic[stacking={4}]{demo}}
{\useMPgraphic[stacking={5}]{demo}}
{\useMPgraphic[stacking={6}]{demo}}
{\useMPgraphic[stacking={7}]{demo}}
{\useMPgraphic[stacking={8}]{demo}}
{\useMPgraphic[stacking={9}]{demo}}
{\useMPgraphic[stacking={10}]{demo}}
\stopanimation
\stoptext


However, I cannot succeed to use \dorecurse to make the code simple.
If there is another good method, please let me know.

Anyway, thanks for this new feature!

How about:

\startuseMPgraphic{demo}
for i=1 upto 10:
draw fullcircle scaled (i*cm/3)
withcolor (i*red/10)
withpen   pencircle scaled (bp/2)
withstacking i
;
endfor ;
\stopuseMPgraphic

\unprotect

\tolerant\protected\def\useMPanimation[#1]#2%
  {\begingroup
   \scratchtoks\emptytoks

\dorecurse{10}{\etoksapp\scratchtoks{{\useMPgraphic[\c!stacking={\recurselevel}]{#2%
   \expanded{\startanimation[#1]\the\scratchtoks\stopanimation}%
   \endgroup}

\protect

\setupinteraction[state=start]

\usemodule[animation]

\starttext
\useMPanimation[menu=yes]{demo}
\stoptext

-
  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
___


Re: [NTG-context] weekend upload

2021-07-12 Thread Jeong Dal
Dear Aditya,

Thank you for your code and an explanation.

> 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}
> 

I tried to reproduce your example using \startuseMPgraphic{boxes} … 
\stopuseMPgraphic, and useMPgraphic[stacking=0]{boxes} .
A modified one of your code is below.
There is no error message but no output at all.
Would you please tell me what is wrong in here?

Best regards,
Dalyoung


\startMPdefinitions
  input boxes;

  primarydef a +- b =
a -- (xpart a, ypart b) -- b
  enddef ;
  primarydef a -+ b =
a -- (xpart b, ypart a) -- b
  enddef ;
\stopMPdefinitions
\defineframed
  [boxframed]
  [
width=6em,
height=2\lineheight,
align={middle,lohi},
background=color,
backgroundcolor=blue,
foregroundcolor=white,
forefroundstyle=bold,
  ]

\startuseMPgraphic[offset=2mm]{boxes}
  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);

  stacking := 0;
  drawunboxed(A,B,C);
  stacking := 1;
  drawarrow A.s +- C.w ;
  drawarrow B.s +- C.e ;

  newpath highlight;

  highlight := (A.sw -- B.se -- B.ne -- A.nw) enlarged EmWidth;
  fill highlight withcolor "darkgray" withstacking -1;

\stopuseMPgraphic

\starttext
\useMPgraphic[stacking={0}]{boxes}
\useMPgraphic[stacking={0,1}]{boxes}
\useMPgraphic[stacking=-1]{boxes}
\stoptext___
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
___


Re: [NTG-context] weekend upload

2021-07-12 Thread Aditya Mahajan
On Tue, 13 Jul 2021, Jeong Dal wrote:

> Dear Aditya,
> 
> Thank you for your code and an explanation.
> 
> > 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}
> > 
> 
> I tried to reproduce your example using \startuseMPgraphic{boxes} … 
> \stopuseMPgraphic, and useMPgraphic[stacking=0]{boxes} .
> A modified one of your code is below.
> There is no error message but no output at all.
> Would you please tell me what is wrong in here?

> [...]
> \startuseMPgraphic[offset=2mm]{boxes}
> [...]

You cannot use [offset=2mm] here. Just use \startuseMPgraphic{boxes}.

Aditya___
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
___


Re: [NTG-context] weekend upload

2021-07-12 Thread Hans Hagen

On 7/12/2021 12:12 PM, Floris van Manen wrote:

with the latest version not everything gets drawn as intended.


$ context --version
mtx-context | ConTeXt Process Management 1.04
mtx-context | current version: 2021.07.10 21:51




On 12/07/2021 10:07, Hans Hagen wrote:
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
indeed, that why i mentioned that the next version will do (but no 
upload today)


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
___


Re: [NTG-context] weekend upload

2021-07-12 Thread Floris van Manen

with the latest version not everything gets drawn as intended.


$ context --version
mtx-context | ConTeXt Process Management 1.04
mtx-context | current version: 2021.07.10 21:51




On 12/07/2021 10:07, Hans Hagen wrote:
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
___
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
___


Re: [NTG-context] weekend upload

2021-07-12 Thread Hans Hagen

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
-
___
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
___


Re: [NTG-context] weekend upload

2021-07-12 Thread Hans Hagen

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".
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
___


Re: [NTG-context] weekend upload

2021-07-11 Thread Aditya Mahajan
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". 

background.pdf
Description: Adobe PDF document


background.tex
Description: TeX document
___
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
___


Re: [NTG-context] weekend upload

2021-07-11 Thread Hans Hagen

On 7/11/2021 3:04 PM, 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.
It's not an animation ... but there are users who make animations with 
mp and then they need stepwise build images so this feature provides 
that (instead of defining 10 different mp graphicss one can dedine just 
one).


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
___


Re: [NTG-context] weekend upload

2021-07-11 Thread Bruce Horrocks


> 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.

—
Bruce Horrocks
Hampshire, UK

___
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
___


Re: [NTG-context] weekend upload

2021-07-10 Thread Hans Hagen

On 7/9/2021 11:33 PM, Aditya Mahajan wrote:



On Fri, 9 Jul 2021, Hans Hagen wrote:


Hi,

This weekend upload has something new for metapost animation lovers:

\starttext

\startuseMPgraphic{demo}
  stacking := 6;
  fill fullcircle scaled 10cm
  withcolor "red" ;
% stacking := 3;
  stacking := 9;
  fill fullcircle scaled 10cm shifted (3cm,0)
  withcolor "green" ;
  interim stacking := 4;
  fill fullcircle scaled 10cm shifted (3cm,3cm)
  withcolor "blue" ;
  for i=1 upto 10 :
  draw fullcircle scaled (i*cm)
  withstacking 8
  withpen  pencircle scaled 1mm
  withcolor"gray" ;
  endfor ;
  for i=1 upto 20 :
  draw fullcircle scaled (i*cm/2)
  withstacking (if odd(i) : i else : 5 fi)
  withpen  pencircle scaled 2mm ;
  endfor ;
  draw boundingbox currentpicture
  withpen  pencircle scaled 1pt
  withstacking 0 ;
  currentpicture := currentpicture xsized 15mm;
\stopuseMPgraphic

\setupMPvariables[demo]

\startTEXpage
  \vskip1ex
  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}}
  \vskip1ex \nointerlineskip
  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}}
  \vskip1ex
\stopTEXpage

\stoptext

I have some more ideas but want to approach it stepwise. It bpils down
to the fact that one can put stuff on different 'layers' and optionally
flush these (by default all are flushed but the stackling order is
honored). An advantage is that one doesn't have to set up a graphic in
order (read: save pictures, flush them later on) and it is actually a
rather cheap extension in terms of runtime and overhead. Although I
could emulate it in mkiv, it is currently an LMTX only feature.

The (optional) list accepts the usual {1,2,5,7-9} kind of specification.


Very interesting. What will be the syntax to use this with \processMPbuffer and 
\startMPcode?

In order to avoid a slash I went for the 'stacking' key:

 \startMPcode[instance=doublefun,stacking=0] % 4
 draw (fullcircle scaled 5cm shifted (0cm,0cm)) withstacking 4;
 draw (fullcircle scaled 5cm shifted (0cm,0cm))
 withpattern image (fill fullcircle scaled 1cm withcolor 
"darkred" ;)

 withpatternscale (1/10,1/10)
 ;
 \stopMPcode

 \startMPpage[offset=1cm,instance=doublefun,stacking=0] % 4
 draw (fullcircle scaled 5cm shifted (0cm,0cm)) withstacking 4;
 draw (fullcircle scaled 5cm shifted (0cm,0cm))
 withpattern image (fill fullcircle scaled 1cm withcolor 
"darkblue";)

 withpatternscale (1/10,1/10)
 ;
 \stopMPpage

we also have optionals to \use.., \reuse.. and \unique..

\startTEXpage
\vskip1ex
\hbox{\space\dorecurse{10}{\useMPgraphic
   {demo}{stacking={0,#1}}\space}}
\vskip1ex \nointerlineskip
\hbox{\space\dorecurse{10}{\useMPgraphic
   {demo}{stacking={0,1-#1}}\space}}
\vskip1ex \nointerlineskip
\hbox{\space\dorecurse{10}{\useMPgraphic
   [instance=doublefun,stacking={0,1-#1}]{demo}\space}}
\vskip1ex
\stopTEXpage

work in progress (new upload anyway, also with clipping fixed wrt stacking)

(i was wondering for a moment if "undergraphic removal" makes sense but 
it is a somewhat costly operation)


(an other feature to explore is not to rerun but use some wrapper that 
keeps the image for as long as we flush ... it might save some runtime 
but first i need to run into a case where it pays off)


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
___


Re: [NTG-context] weekend upload

2021-07-09 Thread Hans Hagen

On 7/9/2021 11:33 PM, Aditya Mahajan wrote:



On Fri, 9 Jul 2021, Hans Hagen wrote:


Hi,

This weekend upload has something new for metapost animation lovers:

\starttext

\startuseMPgraphic{demo}
  stacking := 6;
  fill fullcircle scaled 10cm
  withcolor "red" ;
% stacking := 3;
  stacking := 9;
  fill fullcircle scaled 10cm shifted (3cm,0)
  withcolor "green" ;
  interim stacking := 4;
  fill fullcircle scaled 10cm shifted (3cm,3cm)
  withcolor "blue" ;
  for i=1 upto 10 :
  draw fullcircle scaled (i*cm)
  withstacking 8
  withpen  pencircle scaled 1mm
  withcolor"gray" ;
  endfor ;
  for i=1 upto 20 :
  draw fullcircle scaled (i*cm/2)
  withstacking (if odd(i) : i else : 5 fi)
  withpen  pencircle scaled 2mm ;
  endfor ;
  draw boundingbox currentpicture
  withpen  pencircle scaled 1pt
  withstacking 0 ;
  currentpicture := currentpicture xsized 15mm;
\stopuseMPgraphic

\setupMPvariables[demo]

\startTEXpage
  \vskip1ex
  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}}
  \vskip1ex \nointerlineskip
  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}}
  \vskip1ex
\stopTEXpage

\stoptext

I have some more ideas but want to approach it stepwise. It bpils down
to the fact that one can put stuff on different 'layers' and optionally
flush these (by default all are flushed but the stackling order is
honored). An advantage is that one doesn't have to set up a graphic in
order (read: save pictures, flush them later on) and it is actually a
rather cheap extension in terms of runtime and overhead. Although I
could emulate it in mkiv, it is currently an LMTX only feature.

The (optional) list accepts the usual {1,2,5,7-9} kind of specification.


Very interesting. What will be the syntax to use this with \processMPbuffer and 
\startMPcode?

For now just use:

\setupMPvariables[list=4]

etc (grouped)

btw, i noticed that I need to reset something between graphics

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
___


Re: [NTG-context] weekend upload

2021-07-09 Thread Aditya Mahajan


On Fri, 9 Jul 2021, Hans Hagen wrote:

> Hi,
> 
> This weekend upload has something new for metapost animation lovers:
> 
> \starttext
> 
> \startuseMPgraphic{demo}
>  stacking := 6;
>  fill fullcircle scaled 10cm
>  withcolor "red" ;
>% stacking := 3;
>  stacking := 9;
>  fill fullcircle scaled 10cm shifted (3cm,0)
>  withcolor "green" ;
>  interim stacking := 4;
>  fill fullcircle scaled 10cm shifted (3cm,3cm)
>  withcolor "blue" ;
>  for i=1 upto 10 :
>  draw fullcircle scaled (i*cm)
>  withstacking 8
>  withpen  pencircle scaled 1mm
>  withcolor"gray" ;
>  endfor ;
>  for i=1 upto 20 :
>  draw fullcircle scaled (i*cm/2)
>  withstacking (if odd(i) : i else : 5 fi)
>  withpen  pencircle scaled 2mm ;
>  endfor ;
>  draw boundingbox currentpicture
>  withpen  pencircle scaled 1pt
>  withstacking 0 ;
>  currentpicture := currentpicture xsized 15mm;
> \stopuseMPgraphic
> 
> \setupMPvariables[demo]
> 
> \startTEXpage
>  \vskip1ex
>  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}}
>  \vskip1ex \nointerlineskip
>  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}}
>  \vskip1ex
> \stopTEXpage
> 
> \stoptext
> 
> I have some more ideas but want to approach it stepwise. It bpils down 
> to the fact that one can put stuff on different 'layers' and optionally 
> flush these (by default all are flushed but the stackling order is 
> honored). An advantage is that one doesn't have to set up a graphic in 
> order (read: save pictures, flush them later on) and it is actually a 
> rather cheap extension in terms of runtime and overhead. Although I 
> could emulate it in mkiv, it is currently an LMTX only feature.
> 
> The (optional) list accepts the usual {1,2,5,7-9} kind of specification.

Very interesting. What will be the syntax to use this with \processMPbuffer and 
\startMPcode?

Aditya
___
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
___


Re: [NTG-context] weekend upload

2021-07-09 Thread Hans Hagen

there's an issue with textext that i'll fix

-
  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
___


[NTG-context] weekend upload

2021-07-09 Thread Hans Hagen

Hi,

This weekend upload has something new for metapost animation lovers:

\starttext

\startuseMPgraphic{demo}
stacking := 6;
fill fullcircle scaled 10cm
withcolor "red" ;
  % stacking := 3;
stacking := 9;
fill fullcircle scaled 10cm shifted (3cm,0)
withcolor "green" ;
interim stacking := 4;
fill fullcircle scaled 10cm shifted (3cm,3cm)
withcolor "blue" ;
for i=1 upto 10 :
draw fullcircle scaled (i*cm)
withstacking 8
withpen  pencircle scaled 1mm
withcolor"gray" ;
endfor ;
for i=1 upto 20 :
draw fullcircle scaled (i*cm/2)
withstacking (if odd(i) : i else : 5 fi)
withpen  pencircle scaled 2mm ;
endfor ;
draw boundingbox currentpicture
withpen  pencircle scaled 1pt
withstacking 0 ;
currentpicture := currentpicture xsized 15mm;
\stopuseMPgraphic

\setupMPvariables[demo]

\startTEXpage
\vskip1ex
\hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}}
\vskip1ex \nointerlineskip
\hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}}
\vskip1ex
\stopTEXpage

\stoptext

I have some more ideas but want to approach it stepwise. It bpils down 
to the fact that one can put stuff on different 'layers' and optionally 
flush these (by default all are flushed but the stackling order is 
honored). An advantage is that one doesn't have to set up a graphic in 
order (read: save pictures, flush them later on) and it is actually a 
rather cheap extension in terms of runtime and overhead. Although I 
could emulate it in mkiv, it is currently an LMTX only feature.


The (optional) list accepts the usual {1,2,5,7-9} kind of specification.

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
___