ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] multipage metapost output from ConTeXt
@ 2023-11-27 18:49 Emanuel Han via ntg-context
  2023-11-27 19:56 ` [NTG-context] " Fabrice L
  0 siblings, 1 reply; 12+ messages in thread
From: Emanuel Han via ntg-context @ 2023-11-27 18:49 UTC (permalink / raw)
  To: ntg-context; +Cc: Emanuel Han


[-- Attachment #1.1: Type: text/plain, Size: 4311 bytes --]

How can I achieve multipage metapost output from ConTeXt? The result should be a multipage pdf. It contains just a metapost graphic per page. The graphic has always the same bounding box and evolves from page to page: Some elements to be drawn are added, and some others would ideally also be removed, while keeping elements which has already been drawn on previous pages. I can manage when it is not possible to remove elements (in that case I'll just cover them with a covering element).

I saw that it is possible to achieve my goal with standalone metapost, as described here: https://tex.stackexchange.com/questions/471662/mptopdf-is-multipage-output-pdf-possible
But I'll need to achieve this with Metapost inside ConTeXt because I use labels in Metapost which print text in Japanese, Korean , Arabic and Roman script: Thanks to ConTeXt, I can define appropriate fonts for each script. All this works already in my working example.
The only unsolved problem is to ship out multiple pages.
For the minimal working example, I didn't remove the font defining part, because having 4 different fonts is a condition of my use case. The graphic on the other hand is some simple dummy nonsense graphic not from my project. The graphic is in the provided example drawn as a summing up of layered drawing steps (6 steps, to be precise), so no removing is implemented here (because I don't know how that would be done). If each of the figures 1 to 6 of my mwe can be put alone on a page, I'd be already very happy. Now, they're put on top of each other all on the same single page, also on top of figure 0.
The desired multipage pdf will be used in presentation mode of a pdf viewer and skipped forward and backward from page to page (that is from drawing step to drawing step).
mwe:
\enableregime[utf] % enable unicoded input
\definefontfamily [RomanFont] [rm] [calluna]
\definefontfamily [KoreanFont] [rm] [applemyungjo]
\definefontfamily [JapaneseFont] [rm] [hannotatesc]
\definefontfeature
[fea]
[mode=node,language=dflt,script=arab,
init=yes,
medi=yes,
fina=yes,
isol=yes,
calt=yes,
rlig=yes,
tlig=yes,
trep=yes,
curs=yes,
kern=yes,
mark=yes
]

\starttypescript [serif] [notonaskharabic]
\definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
\stoptypescript

\starttypescript [serif] [notonaskharabic]
\usetypescript[serif][fallback]
\definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
\definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
\definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
\definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
\stoptypescript

\starttypescript [notonaskharabic]
\definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
\stoptypescript

\usetypescript[notonaskharabic]
\setupbodyfont [RomanFont]

\starttext
\startMPcode
picture p[];
path bb; %bounding box

z0 = (0,0);
z1 = (60,40);
z2 = (40,90);
z3 = (10,70);
z4 = (30,50);
z5 = (90,70);
z6 = (-10,70);

path A; A = z0..z1..z2..z3..z4 ;
pair AStartPoint; AStartPoint = point 0 of A;
pair AEndPoint; AEndPoint = point 4 of A;
path B; B = z5..z6;
pair BStartPoint; BStartPoint = point 0 of B;
pair BEndPoint; BEndPoint = point 1 of B;
path C; C = AStartPoint..AEndPoint;

% drawing steps:
p1:=image(
draw A withcolor red;
);

p2:=image(
label(textext("\JapaneseFont 日本語"), AEndPoint);
);

p3:=image(
label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, AStartPoint);
);

p4:=image(
label(textext("\KoreanFont 한국어"), BStartPoint);
);

p5:=image(
label(textext("\RomanFont bāng"), BEndPoint);
draw C withcolor green;
);

p6:=image(
draw B withcolor blue;
);

beginfig(0); %% the whole picture for the common bbox
for k=1 upto 6: draw p[k]; endfor
bb:=bbox(currentpicture);
endfig;

for $=1 upto 6:
beginfig($);
for k=1 upto $: draw p[k]; endfor
setbounds currentpicture to bb;
endfig;
endfor

\stopMPcode
\stoptext


[-- Attachment #1.2: Type: text/html, Size: 6725 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-11-27 18:49 [NTG-context] multipage metapost output from ConTeXt Emanuel Han via ntg-context
@ 2023-11-27 19:56 ` Fabrice L
  2023-11-27 22:25   ` Aditya Mahajan
  0 siblings, 1 reply; 12+ messages in thread
From: Fabrice L @ 2023-11-27 19:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 7193 bytes --]

Hi,

It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion. 

Fabrice.

% 8< -----------------------------------------------

\usecolors[crayola]
\setupMPinstance

\starttext

% We can put in the inclusions the material we will use at each page, to declare things only one time.
\startMPinclusions
 % the frame of the video ;
 path TheFrame ;
 TheFrame := fullsquare scaled 5in ;

 randomseed := 53 ;
 path TheBrownianMotion ;
 pair Coordinate[];
 Coordinate[0] := (0,0);
 TheBrownianMotion := Coordinate[0] ;
 variance := 10 ;
\stopMPinclusions

\dorecurse{600}{ % Frame

\setupMPpage[background=color, backgroundcolor=SpringGreen]
\startMPpage[pagestate=start]

 currentime := #1 ;
 % Just for learning :
 draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
 draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;

Coordinate[currentime] := Coordinate[currentime-1] + %(normaldeviate*variance,normaldeviate*variance) ;
  ((uniformdeviate(1)-0.5)*variance,(uniformdeviate(1)-0.5)*variance) ;
TheBrownianMotion := for p=0 upto (currentime-1) :
  Coordinate[p] .. endfor Coordinate[currentime] ;

draw TheBrownianMotion withpen pencircle scaled .01in withcolor blue ;
draw Coordinate[currentime] withpen pencircle scaled .10in withcolor red ;

setbounds currentpicture to TheFrame ;

desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
currentpicture := currentpicture xysized (desiredformat ,desiredformat );

\stopMPpage

} 

\stoptext
% 8< -----------------------------------------------



> Le 27 nov. 2023 à 13:49, Emanuel Han via ntg-context <ntg-context@ntg.nl> a écrit :
> 
> How can I achieve multipage metapost output from ConTeXt? The result should be a multipage pdf. It contains just a metapost graphic per page. The graphic has always the same bounding box and evolves from page to page: Some elements to be drawn are added, and some others would ideally also be removed, while keeping elements which has already been drawn on previous pages. I can manage when it is not possible to remove elements (in that case I'll just cover them with a covering element).
> 
> I saw that it is possible to achieve my goal with standalone metapost, as described here: https://tex.stackexchange.com/questions/471662/mptopdf-is-multipage-output-pdf-possible
> But I'll need to achieve this with Metapost inside ConTeXt because I use labels in Metapost which print text in Japanese, Korean , Arabic and Roman script: Thanks to ConTeXt, I can define appropriate fonts for each script. All this works already in my working example.
> 
> The only unsolved problem is to ship out multiple pages.
> 
> For the minimal working example, I didn't remove the font defining part, because having 4 different fonts is a condition of my use case. The graphic on the other hand is some simple dummy nonsense graphic not from my project. The graphic is in the provided example drawn as a summing up of layered drawing steps (6 steps, to be precise), so no removing is implemented here (because I don't know how that would be done). If each of the figures 1 to 6 of my mwe can be put alone on a page, I'd be already very happy. Now, they're put on top of each other all on the same single page, also on top of figure 0.
> 
> The desired multipage pdf will be used in presentation mode of a pdf viewer and skipped forward and backward from page to page (that is from drawing step to drawing step).
> 
> mwe:
> 
> \enableregime[utf] % enable unicoded input
> 
> \definefontfamily [RomanFont] [rm] [calluna]
> 
> \definefontfamily [KoreanFont] [rm] [applemyungjo]
> 
> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
> 
> \definefontfeature
>  [fea]
>  [mode=node,language=dflt,script=arab,
>   init=yes,
>   medi=yes,
>   fina=yes,
>   isol=yes,
>   calt=yes,
>   rlig=yes,
>   tlig=yes,
>   trep=yes,
>   curs=yes,
>   kern=yes,
>   mark=yes
> ]
> 
> \starttypescript [serif] [notonaskharabic]
>  \definefontsynonym [notonaskharabic-Light]       [name:notonaskharabic]        [features=fea]
>  \definefontsynonym [notonaskharabic-Bold]        [name:notonaskharabic]        [features=fea]
>  \definefontsynonym [notonaskharabic-Italic]      [name:notonaskharabic]        [features=fea]
>  \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic]        [features=fea]
> \stoptypescript
> 
> \starttypescript [serif] [notonaskharabic]
>  \usetypescript[serif][fallback]
>  \definefontsynonym [Serif]                       [notonaskharabic-Light]       [features=fea]
>  \definefontsynonym [SerifItalic]                 [notonaskharabic-Italic]      [features=fea]
>  \definefontsynonym [SerifBold]                   [notonaskharabic-Bold]        [features=fea]
>  \definefontsynonym [SerifBoldItalic]             [notonaskharabic-Bold-Italic] [features=fea]
> \stoptypescript
> 
> \starttypescript [notonaskharabic]
>   \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
> \stoptypescript
> 
> \usetypescript[notonaskharabic]
> 
> \setupbodyfont [RomanFont]
>    
> 
> \starttext
> 
> \startMPcode
> 
> picture p[];
> path bb; %bounding box
> 
>  z0 = (0,0);   
>  z1 = (60,40);
>  z2 = (40,90); 
>  z3 = (10,70);
>  z4 = (30,50);
>  z5 = (90,70);
>  z6 = (-10,70);
> 
> path A; A = z0..z1..z2..z3..z4 ;
> pair AStartPoint; AStartPoint = point 0 of A;
> pair AEndPoint; AEndPoint = point 4 of A;
> path B; B =  z5..z6;
> pair BStartPoint; BStartPoint = point 0 of B;
> pair BEndPoint; BEndPoint = point 1 of B;
> path C; C = AStartPoint..AEndPoint;
> 
> % drawing steps:       
> p1:=image(
>     draw A withcolor red;
> );
> 
> p2:=image(
>     label(textext("\JapaneseFont 日本語"), AEndPoint);
> );
> 
> p3:=image(
>     label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, AStartPoint);
> );
> 
> p4:=image(
>     label(textext("\KoreanFont 한국어"), BStartPoint);
> );
> 
> p5:=image(
>     label(textext("\RomanFont bāng"), BEndPoint);
>     draw C withcolor green;
> );
> 
> p6:=image(
>     draw B withcolor blue;
> );
> 
> 
> beginfig(0); %% the whole picture for the common bbox
> for k=1 upto 6: draw p[k]; endfor
> bb:=bbox(currentpicture);
> endfig;
>  
> for $=1 upto 6:
> beginfig($);
> for k=1 upto $: draw p[k]; endfor
> setbounds currentpicture  to bb;
> endfig;
> endfor
>  
> \stopMPcode
> \stoptext
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 10145 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-11-27 19:56 ` [NTG-context] " Fabrice L
@ 2023-11-27 22:25   ` Aditya Mahajan
  2023-11-29 11:25     ` Emanuel Han via ntg-context
  0 siblings, 1 reply; 12+ messages in thread
From: Aditya Mahajan @ 2023-11-27 22:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

On Mon, 27 Nov 2023, Fabrice L wrote:

> Hi,
> 
> It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion. 

A very similar option is to pass a variable to a metapost drawing. This is what I use:

https://adityam.github.io/context-blog/post/metapost-animation/

It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.

Aditya

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-11-27 22:25   ` Aditya Mahajan
@ 2023-11-29 11:25     ` Emanuel Han via ntg-context
  2023-12-02 11:22       ` Emanuel Han via ntg-context
  0 siblings, 1 reply; 12+ messages in thread
From: Emanuel Han via ntg-context @ 2023-11-29 11:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Emanuel Han


[-- Attachment #1.1: Type: text/plain, Size: 5083 bytes --]

Dear Aditya and Fabrice,
thanks for your responses.

I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
What is bizarre is that issues appear now that didn't appear before:
Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.

textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.

Adjusted mwe:

\enableregime[utf] % enable unicoded input
\definefontfamily [RomanFont] [rm] [calluna]
\definefontfamily [KoreanFont] [rm] [applemyungjo]
\definefontfamily [JapaneseFont] [rm] [hannotatesc]
\definefontfeature
[fea]
[mode=node,language=dflt,script=arab,
init=yes,
medi=yes,
fina=yes,
isol=yes,
calt=yes,
rlig=yes,
tlig=yes,
trep=yes,
curs=yes,
kern=yes,
mark=yes
]

\starttypescript [serif] [notonaskharabic]
\definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
\definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
\stoptypescript

\starttypescript [serif] [notonaskharabic]
\usetypescript[serif][fallback]
\definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
\definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
\definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
\definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
\stoptypescript

\starttypescript [notonaskharabic]
\definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
\stoptypescript

\usetypescript[notonaskharabic]
\setupbodyfont [RomanFont]

\usecolors[crayola]

\startMPinclusions
picture p[];
path TheFrame ;
TheFrame := fullsquare scaled 5in ;

z0 = (0,0);
z1 = (60,40);
z2 = (40,90);
z3 = (10,70);
z4 = (30,50);
z5 = (90,70);
z6 = (-10,70);

path A; A = z0..z1..z2..z3..z4 ;
pair AStartPoint; AStartPoint = point 0 of A;
pair AEndPoint; AEndPoint = point 4 of A;
path B; B = z5..z6;
pair BStartPoint; BStartPoint = point 0 of B;
pair BEndPoint; BEndPoint = point 1 of B;
path C; C = AStartPoint..AEndPoint;

p1:=image(
draw A withcolor red;
);

p2:=image(draw A; label(lmt_outline [
text = "\JapaneseFont 日本語"
], AEndPoint););

p3:=image(
label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
);

p4:=image(draw A; label(lmt_outline [
text = "\KoreanFont 한국어"
], AStartPoint););

p5:=image(
label(textext("bāng"), BEndPoint);
draw C withcolor green;
);

p6:=image(
draw B withcolor blue;
);
\stopMPinclusions

\starttext
\dorecurse{6}{ % Frame
\setupMPpage[background=color, backgroundcolor=SpringGreen]
\startMPpage[pagestate=start]
currentime := #1 ;
% Just for learning :
draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
for k=1 upto currentime: draw p[k]; endfor
setbounds currentpicture to TheFrame ;

desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
currentpicture := currentpicture xysized (desiredformat ,desiredformat );

\stopMPpage
}

\stoptext
On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
> On Mon, 27 Nov 2023, Fabrice L wrote:
>
> > Hi,
> >
> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
>
> A very similar option is to pass a variable to a metapost drawing. This is what I use:
> https://adityam.github.io/context-blog/post/metapost-animation/
> It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> Aditya___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________
>


[-- Attachment #1.2: Type: text/html, Size: 7618 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-11-29 11:25     ` Emanuel Han via ntg-context
@ 2023-12-02 11:22       ` Emanuel Han via ntg-context
  2023-12-02 11:54         ` fv leung
  0 siblings, 1 reply; 12+ messages in thread
From: Emanuel Han via ntg-context @ 2023-12-02 11:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Emanuel Han


[-- Attachment #1.1: Type: text/plain, Size: 6113 bytes --]

So is there a way to circumvent these issues? Or an explanation for this behavior, so that I can try to find a solution by myself?

Thanks
Emanuel

On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> Dear Aditya and Fabrice,
> thanks for your responses.
>
> I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
> What is bizarre is that issues appear now that didn't appear before:
> Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.
>
> textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.
>
>
> Adjusted mwe:
>
> \enableregime[utf] % enable unicoded input
> \definefontfamily [RomanFont] [rm] [calluna]
> \definefontfamily [KoreanFont] [rm] [applemyungjo]
> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
> \definefontfeature
> [fea]
> [mode=node,language=dflt,script=arab,
> init=yes,
> medi=yes,
> fina=yes,
> isol=yes,
> calt=yes,
> rlig=yes,
> tlig=yes,
> trep=yes,
> curs=yes,
> kern=yes,
> mark=yes
> ]
>
> \starttypescript [serif] [notonaskharabic]
> \definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
> \definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
> \definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
> \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
> \stoptypescript
>
> \starttypescript [serif] [notonaskharabic]
> \usetypescript[serif][fallback]
> \definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
> \definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
> \definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
> \definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
> \stoptypescript
>
> \starttypescript [notonaskharabic]
> \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
> \stoptypescript
>
> \usetypescript[notonaskharabic]
> \setupbodyfont [RomanFont]
>
> \usecolors[crayola]
>
> \startMPinclusions
> picture p[];
> path TheFrame ;
> TheFrame := fullsquare scaled 5in ;
>
> z0 = (0,0);
> z1 = (60,40);
> z2 = (40,90);
> z3 = (10,70);
> z4 = (30,50);
> z5 = (90,70);
> z6 = (-10,70);
>
> path A; A = z0..z1..z2..z3..z4 ;
> pair AStartPoint; AStartPoint = point 0 of A;
> pair AEndPoint; AEndPoint = point 4 of A;
> path B; B = z5..z6;
> pair BStartPoint; BStartPoint = point 0 of B;
> pair BEndPoint; BEndPoint = point 1 of B;
> path C; C = AStartPoint..AEndPoint;
>
> p1:=image(
> draw A withcolor red;
> );
>
> p2:=image(draw A; label(lmt_outline [
> text = "\JapaneseFont 日本語"
> ], AEndPoint););
>
> p3:=image(
> label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
> );
>
> p4:=image(draw A; label(lmt_outline [
> text = "\KoreanFont 한국어"
> ], AStartPoint););
>
> p5:=image(
> label(textext("bāng"), BEndPoint);
> draw C withcolor green;
> );
>
> p6:=image(
> draw B withcolor blue;
> );
> \stopMPinclusions
>
> \starttext
> \dorecurse{6}{ % Frame
> \setupMPpage[background=color, backgroundcolor=SpringGreen]
> \startMPpage[pagestate=start]
> currentime := #1 ;
> % Just for learning :
> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> for k=1 upto currentime: draw p[k]; endfor
> setbounds currentpicture to TheFrame ;
>
> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
>
> \stopMPpage
> }
>
> \stoptext
> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
> > On Mon, 27 Nov 2023, Fabrice L wrote:
> >
> > > Hi,
> > >
> > > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
> >
> > A very similar option is to pass a variable to a metapost drawing. This is what I use:
> > https://adityam.github.io/context-blog/post/metapost-animation/
> > It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> > Aditya___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / 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
> > ___________________________________________________________________________________
> >
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 8482 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-12-02 11:22       ` Emanuel Han via ntg-context
@ 2023-12-02 11:54         ` fv leung
  2023-12-02 16:22           ` Mikael Sundqvist
  0 siblings, 1 reply; 12+ messages in thread
From: fv leung @ 2023-12-02 11:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 7155 bytes --]

You didn't specify the color of path A in p2 and p4. So it's drawn in black.
The other issue, I can't help.

Emanuel Han via ntg-context <ntg-context@ntg.nl> 於 2023年12月2日 週六 下午7:23寫道:

> So is there a way to circumvent these issues? Or an explanation for this
> behavior, so that I can try to find a solution by myself?
>
> Thanks
> Emanuel
>
> On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <
> ntg-context@ntg.nl> wrote:
>
> Dear Aditya and Fabrice,
> thanks for your responses.
>
> I included some of Fabrice's code into mine for testing purpose, and
> indeed the multipage works now.
> What is bizarre is that issues appear now that didn't appear before:
>
>    - Path A is drawn with color red on page 1, and in color black on all
>    following pages, while it should stay red.
>    - textext(<text>, <pair>) is overwriting <text> with
>    "T="&decimal(currentime) which has been used previously  in textext()
>    before the for k=1 endfor loop. This overwriting happens only for the first
>    textext() which occurs inside the for k=1 endfor loop. All other textext()
>    inside the for k=1 endfor loop are not drawn at all. If the line  « draw
>    textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta
>    ; » is commented out, the first textext() inside the for k=1 endfor loop is
>    not drawn neither. It must be an issue with textext(), because when I
>    replace textext() by lmt_outline[], the text is drawn.
>
> Adjusted mwe:
>
> \enableregime[utf] % enable unicoded input
>
> \definefontfamily [RomanFont] [rm] [calluna]
>
> \definefontfamily [KoreanFont] [rm] [applemyungjo]
>
> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
>
> \definefontfeature
>  [fea]
>  [mode=node,language=dflt,script=arab,
>   init=yes,
>   medi=yes,
>   fina=yes,
>   isol=yes,
>   calt=yes,
>   rlig=yes,
>   tlig=yes,
>   trep=yes,
>   curs=yes,
>   kern=yes,
>   mark=yes
> ]
>
> \starttypescript [serif] [notonaskharabic]
>  \definefontsynonym [notonaskharabic-Light]
> [name:notonaskharabic]        [features=fea]
>  \definefontsynonym [notonaskharabic-Bold]
> [name:notonaskharabic]        [features=fea]
>  \definefontsynonym [notonaskharabic-Italic]
> [name:notonaskharabic]        [features=fea]
>  \definefontsynonym [notonaskharabic-Bold-Italic]
> [name:notonaskharabic]        [features=fea]
> \stoptypescript
>
> \starttypescript [serif] [notonaskharabic]
>  \usetypescript[serif][fallback]
>  \definefontsynonym [Serif]
> [notonaskharabic-Light]       [features=fea]
>  \definefontsynonym [SerifItalic]
> [notonaskharabic-Italic]      [features=fea]
>  \definefontsynonym [SerifBold]
> [notonaskharabic-Bold]        [features=fea]
>  \definefontsynonym [SerifBoldItalic]
> [notonaskharabic-Bold-Italic] [features=fea]
> \stoptypescript
>
> \starttypescript [notonaskharabic]
>   \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic]
> [default]
> \stoptypescript
>
> \usetypescript[notonaskharabic]
>
> \setupbodyfont [RomanFont]
>
> \usecolors[crayola]
>
> \startMPinclusions
>
> picture p[];
>  path TheFrame ;
>  TheFrame := fullsquare scaled 5in ;
>
>  z0 = (0,0);
>  z1 = (60,40);
>  z2 = (40,90);
>  z3 = (10,70);
>  z4 = (30,50);
>  z5 = (90,70);
>  z6 = (-10,70);
>
> path A; A = z0..z1..z2..z3..z4 ;
> pair AStartPoint; AStartPoint = point 0 of A;
> pair AEndPoint; AEndPoint = point 4 of A;
> path B; B =  z5..z6;
> pair BStartPoint; BStartPoint = point 0 of B;
> pair BEndPoint; BEndPoint = point 1 of B;
> path C; C = AStartPoint..AEndPoint;
>
> p1:=image(
>     draw A withcolor red;
> );
>
> p2:=image(draw A; label(lmt_outline [
> text = "\JapaneseFont 日本語"
>     ], AEndPoint););
>
> p3:=image(
>     label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2,
> BStartPoint);
> );
>
> p4:=image(draw A; label(lmt_outline [
> text = "\KoreanFont 한국어"
>     ], AStartPoint););
>
> p5:=image(
>     label(textext("bāng"), BEndPoint);
>     draw C withcolor green;
> );
>
> p6:=image(
>     draw B withcolor blue;
> );
> \stopMPinclusions
>
> \starttext
>
> \dorecurse{6}{ % Frame
>  \setupMPpage[background=color, backgroundcolor=SpringGreen]
> \startMPpage[pagestate=start]
>  currentime := #1 ;
>  % Just for learning :
>  draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
>  draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor
> magenta ;
>  for k=1 upto currentime: draw p[k]; endfor
>  setbounds currentpicture to TheFrame ;
>
>  desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
>  currentpicture := currentpicture xysized (desiredformat ,desiredformat );
>
> \stopMPpage
> }
>
> \stoptext
> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
>
> On Mon, 27 Nov 2023, Fabrice L wrote:
>
> > Hi,
> >
> > It is fun fact very easy to do. You just use \startMPpage (…)
> \stopMPpage multiple times. Here is an example which build an animation of
> a particle moving according to a Brownian motion.
>
> A very similar option is to pass a variable to a metapost drawing. This is
> what I use:
>
> https://adityam.github.io/context-blog/post/metapost-animation/
>
> It only works when viewed in acrobat, you can just comment out the
> animation part and wrap it in \startTEXpage .. \stopTEXpage to get
> multi-page animation.
>
>
> Aditya___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> 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
>
> ___________________________________________________________________________________
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> 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
>
> ___________________________________________________________________________________
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> 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
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 10185 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-12-02 11:54         ` fv leung
@ 2023-12-02 16:22           ` Mikael Sundqvist
  2023-12-02 17:08             ` Emanuel Han via ntg-context
  0 siblings, 1 reply; 12+ messages in thread
From: Mikael Sundqvist @ 2023-12-02 16:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Emanuel,

I am not sure I understand your question, and since you use fonts that
i do not have, I cannot test your example as is. But, maybe, if you
want to redraw a picture, you can do

addto currentpicture also p1;

where you want it.

/Mikael

PS For the text thing, I did not get it. Could one have a _very
simple_ example showing only that problem and no other problem?

On Sat, Dec 2, 2023 at 12:58 PM fv leung <fvleung@gmail.com> wrote:
>
> You didn't specify the color of path A in p2 and p4. So it's drawn in black.
> The other issue, I can't help.
>
> Emanuel Han via ntg-context <ntg-context@ntg.nl> 於 2023年12月2日 週六 下午7:23寫道:
>>
>> So is there a way to circumvent these issues? Or an explanation for this behavior, so that I can try to find a solution by myself?
>>
>> Thanks
>> Emanuel
>>
>> On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
>>
>> Dear Aditya and Fabrice,
>> thanks for your responses.
>>
>> I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
>> What is bizarre is that issues appear now that didn't appear before:
>>
>> Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.
>> textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously  in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line  « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.
>>
>> Adjusted mwe:
>>
>> \enableregime[utf] % enable unicoded input
>>
>> \definefontfamily [RomanFont] [rm] [calluna]
>>
>> \definefontfamily [KoreanFont] [rm] [applemyungjo]
>>
>> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
>>
>> \definefontfeature
>>  [fea]
>>  [mode=node,language=dflt,script=arab,
>>   init=yes,
>>   medi=yes,
>>   fina=yes,
>>   isol=yes,
>>   calt=yes,
>>   rlig=yes,
>>   tlig=yes,
>>   trep=yes,
>>   curs=yes,
>>   kern=yes,
>>   mark=yes
>> ]
>>
>> \starttypescript [serif] [notonaskharabic]
>>  \definefontsynonym [notonaskharabic-Light]       [name:notonaskharabic]        [features=fea]
>>  \definefontsynonym [notonaskharabic-Bold]        [name:notonaskharabic]        [features=fea]
>>  \definefontsynonym [notonaskharabic-Italic]      [name:notonaskharabic]        [features=fea]
>>  \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic]        [features=fea]
>> \stoptypescript
>>
>> \starttypescript [serif] [notonaskharabic]
>>  \usetypescript[serif][fallback]
>>  \definefontsynonym [Serif]                       [notonaskharabic-Light]       [features=fea]
>>  \definefontsynonym [SerifItalic]                 [notonaskharabic-Italic]      [features=fea]
>>  \definefontsynonym [SerifBold]                   [notonaskharabic-Bold]        [features=fea]
>>  \definefontsynonym [SerifBoldItalic]             [notonaskharabic-Bold-Italic] [features=fea]
>> \stoptypescript
>>
>> \starttypescript [notonaskharabic]
>>   \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
>> \stoptypescript
>>
>> \usetypescript[notonaskharabic]
>>
>> \setupbodyfont [RomanFont]
>>
>> \usecolors[crayola]
>>
>> \startMPinclusions
>>
>> picture p[];
>>  path TheFrame ;
>>  TheFrame := fullsquare scaled 5in ;
>>
>>  z0 = (0,0);
>>  z1 = (60,40);
>>  z2 = (40,90);
>>  z3 = (10,70);
>>  z4 = (30,50);
>>  z5 = (90,70);
>>  z6 = (-10,70);
>>
>> path A; A = z0..z1..z2..z3..z4 ;
>> pair AStartPoint; AStartPoint = point 0 of A;
>> pair AEndPoint; AEndPoint = point 4 of A;
>> path B; B =  z5..z6;
>> pair BStartPoint; BStartPoint = point 0 of B;
>> pair BEndPoint; BEndPoint = point 1 of B;
>> path C; C = AStartPoint..AEndPoint;
>>
>> p1:=image(
>>     draw A withcolor red;
>> );
>>
>> p2:=image(draw A; label(lmt_outline [
>> text = "\JapaneseFont 日本語"
>>     ], AEndPoint););
>>
>> p3:=image(
>>     label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
>> );
>>
>> p4:=image(draw A; label(lmt_outline [
>> text = "\KoreanFont 한국어"
>>     ], AStartPoint););
>>
>> p5:=image(
>>     label(textext("bāng"), BEndPoint);
>>     draw C withcolor green;
>> );
>>
>> p6:=image(
>>     draw B withcolor blue;
>> );
>> \stopMPinclusions
>>
>> \starttext
>>
>> \dorecurse{6}{ % Frame
>>  \setupMPpage[background=color, backgroundcolor=SpringGreen]
>> \startMPpage[pagestate=start]
>>  currentime := #1 ;
>>  % Just for learning :
>>  draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
>>  draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
>>  for k=1 upto currentime: draw p[k]; endfor
>>  setbounds currentpicture to TheFrame ;
>>
>>  desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
>>  currentpicture := currentpicture xysized (desiredformat ,desiredformat );
>>
>> \stopMPpage
>> }
>>
>> \stoptext
>> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
>>
>> On Mon, 27 Nov 2023, Fabrice L wrote:
>>
>> > Hi,
>> >
>> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
>>
>> A very similar option is to pass a variable to a metapost drawing. This is what I use:
>>
>> https://adityam.github.io/context-blog/post/metapost-animation/
>>
>> It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
>>
>> Aditya___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / 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
>> ___________________________________________________________________________________
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / 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
>> ___________________________________________________________________________________
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context@ntg.nl / 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
>> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-12-02 16:22           ` Mikael Sundqvist
@ 2023-12-02 17:08             ` Emanuel Han via ntg-context
  2023-12-02 18:46               ` Mikael Sundqvist
  2023-12-04 16:35               ` Fabrice L
  0 siblings, 2 replies; 12+ messages in thread
From: Emanuel Han via ntg-context @ 2023-12-02 17:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Emanuel Han


[-- Attachment #1.1: Type: text/plain, Size: 10132 bytes --]

Hi Mikael,

here's a very simple mwe for the label(textext()) issue. On page 1, the text "Word 1" should be drawn in position z1. On page 2, the same text in the same position should be visible, and the text "Mot 2" in position p2 should be added. And so on.
\startMPinclusions
picture p[];
path TheFrame ;
TheFrame := fullsquare scaled 5in ;

z1 = (60,40);
z2 = (40,90);
z3 = (10,70);

p1:=image(
label(textext("Word 1"), z1);
);

p2:=image(
label(textext("Mot 2"), z2);
);

p3:=image(
label(textext("Parola 3"), z3);
);

\stopMPinclusions
\starttext
\dorecurse{3}{ % Frame
\startMPpage[pagestate=start]
currentime := #1 ;
% Just for learning :
draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
for k=1 upto currentime: draw p[k]; endfor
setbounds currentpicture to TheFrame ;

desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
currentpicture := currentpicture xysized (desiredformat ,desiredformat );

\stopMPpage
}

\stoptext
On Dez. 2 2023, at 5:22 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
> Hi Emanuel,
>
> I am not sure I understand your question, and since you use fonts that
> i do not have, I cannot test your example as is. But, maybe, if you
> want to redraw a picture, you can do
>
> addto currentpicture also p1;
> where you want it.
> /Mikael
> PS For the text thing, I did not get it. Could one have a _very
> simple_ example showing only that problem and no other problem?
>
> On Sat, Dec 2, 2023 at 12:58 PM fv leung <fvleung@gmail.com> wrote:
> >
> > You didn't specify the color of path A in p2 and p4. So it's drawn in black.
> > The other issue, I can't help.
> >
> > Emanuel Han via ntg-context <ntg-context@ntg.nl> 於 2023年12月2日 週六 下午7:23寫道:
> >>
> >> So is there a way to circumvent these issues? Or an explanation for this behavior, so that I can try to find a solution by myself?
> >>
> >> Thanks
> >> Emanuel
> >>
> >> On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >>
> >> Dear Aditya and Fabrice,
> >> thanks for your responses.
> >>
> >> I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
> >> What is bizarre is that issues appear now that didn't appear before:
> >>
> >> Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.
> >> textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.
> >>
> >> Adjusted mwe:
> >>
> >> \enableregime[utf] % enable unicoded input
> >>
> >> \definefontfamily [RomanFont] [rm] [calluna]
> >>
> >> \definefontfamily [KoreanFont] [rm] [applemyungjo]
> >>
> >> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
> >>
> >> \definefontfeature
> >> [fea]
> >> [mode=node,language=dflt,script=arab,
> >> init=yes,
> >> medi=yes,
> >> fina=yes,
> >> isol=yes,
> >> calt=yes,
> >> rlig=yes,
> >> tlig=yes,
> >> trep=yes,
> >> curs=yes,
> >> kern=yes,
> >> mark=yes
> >> ]
> >>
> >> \starttypescript [serif] [notonaskharabic]
> >> \definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
> >> \stoptypescript
> >>
> >> \starttypescript [serif] [notonaskharabic]
> >> \usetypescript[serif][fallback]
> >> \definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
> >> \definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
> >> \definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
> >> \definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
> >> \stoptypescript
> >>
> >> \starttypescript [notonaskharabic]
> >> \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
> >> \stoptypescript
> >>
> >> \usetypescript[notonaskharabic]
> >>
> >> \setupbodyfont [RomanFont]
> >>
> >> \usecolors[crayola]
> >>
> >> \startMPinclusions
> >>
> >> picture p[];
> >> path TheFrame ;
> >> TheFrame := fullsquare scaled 5in ;
> >>
> >> z0 = (0,0);
> >> z1 = (60,40);
> >> z2 = (40,90);
> >> z3 = (10,70);
> >> z4 = (30,50);
> >> z5 = (90,70);
> >> z6 = (-10,70);
> >>
> >> path A; A = z0..z1..z2..z3..z4 ;
> >> pair AStartPoint; AStartPoint = point 0 of A;
> >> pair AEndPoint; AEndPoint = point 4 of A;
> >> path B; B = z5..z6;
> >> pair BStartPoint; BStartPoint = point 0 of B;
> >> pair BEndPoint; BEndPoint = point 1 of B;
> >> path C; C = AStartPoint..AEndPoint;
> >>
> >> p1:=image(
> >> draw A withcolor red;
> >> );
> >>
> >> p2:=image(draw A; label(lmt_outline [
> >> text = "\JapaneseFont 日本語"
> >> ], AEndPoint););
> >>
> >> p3:=image(
> >> label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
> >> );
> >>
> >> p4:=image(draw A; label(lmt_outline [
> >> text = "\KoreanFont 한국어"
> >> ], AStartPoint););
> >>
> >> p5:=image(
> >> label(textext("bāng"), BEndPoint);
> >> draw C withcolor green;
> >> );
> >>
> >> p6:=image(
> >> draw B withcolor blue;
> >> );
> >> \stopMPinclusions
> >>
> >> \starttext
> >>
> >> \dorecurse{6}{ % Frame
> >> \setupMPpage[background=color, backgroundcolor=SpringGreen]
> >> \startMPpage[pagestate=start]
> >> currentime := #1 ;
> >> % Just for learning :
> >> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> >> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> >> for k=1 upto currentime: draw p[k]; endfor
> >> setbounds currentpicture to TheFrame ;
> >>
> >> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> >> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> >>
> >> \stopMPpage
> >> }
> >>
> >> \stoptext
> >> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
> >>
> >> On Mon, 27 Nov 2023, Fabrice L wrote:
> >>
> >> > Hi,
> >> >
> >> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
> >>
> >> A very similar option is to pass a variable to a metapost drawing. This is what I use:
> >>
> >> https://adityam.github.io/context-blog/post/metapost-animation/
> >>
> >> It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> >>
> >> Aditya___________________________________________________________________________________
> >> If your question is of interest to others as well, please add an entry to the Wiki!
> >>
> >> maillist : ntg-context@ntg.nl / 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
> >> ___________________________________________________________________________________
> >>
> >> ___________________________________________________________________________________
> >> If your question is of interest to others as well, please add an entry to the Wiki!
> >>
> >> maillist : ntg-context@ntg.nl / 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
> >> ___________________________________________________________________________________
> >>
> >> ___________________________________________________________________________________
> >> If your question is of interest to others as well, please add an entry to the Wiki!
> >>
> >> maillist : ntg-context@ntg.nl / 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
> >> ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / 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
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________
>


[-- Attachment #1.2: Type: text/html, Size: 13348 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-12-02 17:08             ` Emanuel Han via ntg-context
@ 2023-12-02 18:46               ` Mikael Sundqvist
  2023-12-02 22:51                 ` Emanuel Han via ntg-context
  2024-01-06 16:33                 ` Emanuel Han via ntg-context
  2023-12-04 16:35               ` Fabrice L
  1 sibling, 2 replies; 12+ messages in thread
From: Mikael Sundqvist @ 2023-12-02 18:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

I don't know if \startMPinclusions \stopMPinclusions shall work with
\startMPpage and \stopMPpage. In this case, one can use a separate
graphics:

\startuseMPgraphic{base}

picture p[];
path TheFrame ;
TheFrame := fullsquare scaled 5in ;
z1 = (60,40);
z2 = (40,90);
z3 = (10,70);

p1:=image(
label("Word 1", z1);
);

p2:=image(
label("Mot 2", z2);
);

p3:=image(
label("Parola 3", z3);
);

\stopuseMPgraphic

\starttext

\dorecurse{3}{ % Frame

\startMPpage[pagestate=start]

\includeMPgraphic{base}

currentime := #1 ;
% Just for learning :
draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in)
withcolor magenta ;
for k=1 upto currentime: addto currentpicture also p[k]; endfor
setbounds currentpicture to TheFrame ;

desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
currentpicture := currentpicture xysized (desiredformat ,desiredformat );
\stopMPpage
}

\stoptext

/Mikael

On Sat, Dec 2, 2023 at 6:14 PM Emanuel Han via ntg-context
<ntg-context@ntg.nl> wrote:
>
> Hi Mikael,
>
> here's a very simple mwe for the label(textext()) issue. On page 1, the text "Word 1" should be drawn in position z1. On page 2, the same text in the same position should be visible, and the text "Mot 2" in position p2 should be added. And so on.
>
> \startMPinclusions
>
> picture p[];
>  path TheFrame ;
>  TheFrame := fullsquare scaled 5in ;
>
>  z1 = (60,40);
>  z2 = (40,90);
>  z3 = (10,70);
>
> p1:=image(
>     label(textext("Word 1"), z1);
> );
>
> p2:=image(
>     label(textext("Mot 2"), z2);
> );
>
> p3:=image(
>     label(textext("Parola 3"), z3);
> );
>
> \stopMPinclusions
>
> \starttext
>
> \dorecurse{3}{ % Frame
> \startMPpage[pagestate=start]
>  currentime := #1 ;
>  % Just for learning :
>  draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
>  draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
>  for k=1 upto currentime: draw p[k]; endfor
>  setbounds currentpicture to TheFrame ;
>
>  desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
>  currentpicture := currentpicture xysized (desiredformat ,desiredformat );
>
> \stopMPpage
> }
>
> \stoptext
>
> On Dez. 2 2023, at 5:22 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
>
> Hi Emanuel,
>
> I am not sure I understand your question, and since you use fonts that
> i do not have, I cannot test your example as is. But, maybe, if you
> want to redraw a picture, you can do
>
> addto currentpicture also p1;
>
> where you want it.
>
> /Mikael
>
> PS For the text thing, I did not get it. Could one have a _very
> simple_ example showing only that problem and no other problem?
>
> On Sat, Dec 2, 2023 at 12:58 PM fv leung <fvleung@gmail.com> wrote:
> >
> > You didn't specify the color of path A in p2 and p4. So it's drawn in black.
> > The other issue, I can't help.
> >
> > Emanuel Han via ntg-context <ntg-context@ntg.nl> 於 2023年12月2日 週六 下午7:23寫道:
> >>
> >> So is there a way to circumvent these issues? Or an explanation for this behavior, so that I can try to find a solution by myself?
> >>
> >> Thanks
> >> Emanuel
> >>
> >> On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >>
> >> Dear Aditya and Fabrice,
> >> thanks for your responses.
> >>
> >> I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
> >> What is bizarre is that issues appear now that didn't appear before:
> >>
> >> Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.
> >> textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.
> >>
> >> Adjusted mwe:
> >>
> >> \enableregime[utf] % enable unicoded input
> >>
> >> \definefontfamily [RomanFont] [rm] [calluna]
> >>
> >> \definefontfamily [KoreanFont] [rm] [applemyungjo]
> >>
> >> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
> >>
> >> \definefontfeature
> >> [fea]
> >> [mode=node,language=dflt,script=arab,
> >> init=yes,
> >> medi=yes,
> >> fina=yes,
> >> isol=yes,
> >> calt=yes,
> >> rlig=yes,
> >> tlig=yes,
> >> trep=yes,
> >> curs=yes,
> >> kern=yes,
> >> mark=yes
> >> ]
> >>
> >> \starttypescript [serif] [notonaskharabic]
> >> \definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
> >> \stoptypescript
> >>
> >> \starttypescript [serif] [notonaskharabic]
> >> \usetypescript[serif][fallback]
> >> \definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
> >> \definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
> >> \definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
> >> \definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
> >> \stoptypescript
> >>
> >> \starttypescript [notonaskharabic]
> >> \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
> >> \stoptypescript
> >>
> >> \usetypescript[notonaskharabic]
> >>
> >> \setupbodyfont [RomanFont]
> >>
> >> \usecolors[crayola]
> >>
> >> \startMPinclusions
> >>
> >> picture p[];
> >> path TheFrame ;
> >> TheFrame := fullsquare scaled 5in ;
> >>
> >> z0 = (0,0);
> >> z1 = (60,40);
> >> z2 = (40,90);
> >> z3 = (10,70);
> >> z4 = (30,50);
> >> z5 = (90,70);
> >> z6 = (-10,70);
> >>
> >> path A; A = z0..z1..z2..z3..z4 ;
> >> pair AStartPoint; AStartPoint = point 0 of A;
> >> pair AEndPoint; AEndPoint = point 4 of A;
> >> path B; B = z5..z6;
> >> pair BStartPoint; BStartPoint = point 0 of B;
> >> pair BEndPoint; BEndPoint = point 1 of B;
> >> path C; C = AStartPoint..AEndPoint;
> >>
> >> p1:=image(
> >> draw A withcolor red;
> >> );
> >>
> >> p2:=image(draw A; label(lmt_outline [
> >> text = "\JapaneseFont 日本語"
> >> ], AEndPoint););
> >>
> >> p3:=image(
> >> label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
> >> );
> >>
> >> p4:=image(draw A; label(lmt_outline [
> >> text = "\KoreanFont 한국어"
> >> ], AStartPoint););
> >>
> >> p5:=image(
> >> label(textext("bāng"), BEndPoint);
> >> draw C withcolor green;
> >> );
> >>
> >> p6:=image(
> >> draw B withcolor blue;
> >> );
> >> \stopMPinclusions
> >>
> >> \starttext
> >>
> >> \dorecurse{6}{ % Frame
> >> \setupMPpage[background=color, backgroundcolor=SpringGreen]
> >> \startMPpage[pagestate=start]
> >> currentime := #1 ;
> >> % Just for learning :
> >> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> >> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> >> for k=1 upto currentime: draw p[k]; endfor
> >> setbounds currentpicture to TheFrame ;
> >>
> >> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> >> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> >>
> >> \stopMPpage
> >> }
> >>
> >> \stoptext
> >> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
> >>
> >> On Mon, 27 Nov 2023, Fabrice L wrote:
> >>
> >> > Hi,
> >> >
> >> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
> >>
> >> A very similar option is to pass a variable to a metapost drawing. This is what I use:
> >>
> >> https://adityam.github.io/context-blog/post/metapost-animation/
> >>
> >> It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> >>
> >> Aditya___________________________________________________________________________________
> >> If your question is of interest to others as well, please add an entry to the Wiki!
> >>
> >> maillist : ntg-context@ntg.nl / 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
> >> ___________________________________________________________________________________
> >>
> >> ___________________________________________________________________________________
> >> If your question is of interest to others as well, please add an entry to the Wiki!
> >>
> >> maillist : ntg-context@ntg.nl / 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
> >> ___________________________________________________________________________________
> >>
> >> ___________________________________________________________________________________
> >> If your question is of interest to others as well, please add an entry to the Wiki!
> >>
> >> maillist : ntg-context@ntg.nl / 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
> >> ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / 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
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-12-02 18:46               ` Mikael Sundqvist
@ 2023-12-02 22:51                 ` Emanuel Han via ntg-context
  2024-01-06 16:33                 ` Emanuel Han via ntg-context
  1 sibling, 0 replies; 12+ messages in thread
From: Emanuel Han via ntg-context @ 2023-12-02 22:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Emanuel Han


[-- Attachment #1.1: Type: text/plain, Size: 13155 bytes --]

Thank you Mikael,
this works!
Emanuel

On Dez. 2 2023, at 7:46 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
> Hi,
>
> I don't know if \startMPinclusions \stopMPinclusions shall work with
> \startMPpage and \stopMPpage. In this case, one can use a separate
> graphics:
>
> \startuseMPgraphic{base}
> picture p[];
> path TheFrame ;
> TheFrame := fullsquare scaled 5in ;
> z1 = (60,40);
> z2 = (40,90);
> z3 = (10,70);
>
> p1:=image(
> label("Word 1", z1);
> );
>
> p2:=image(
> label("Mot 2", z2);
> );
>
> p3:=image(
> label("Parola 3", z3);
> );
>
> \stopuseMPgraphic
> \starttext
> \dorecurse{3}{ % Frame
> \startMPpage[pagestate=start]
> \includeMPgraphic{base}
> currentime := #1 ;
> % Just for learning :
> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in)
> withcolor magenta ;
> for k=1 upto currentime: addto currentpicture also p[k]; endfor
> setbounds currentpicture to TheFrame ;
>
> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> \stopMPpage
> }
>
> \stoptext
> /Mikael
> On Sat, Dec 2, 2023 at 6:14 PM Emanuel Han via ntg-context
> <ntg-context@ntg.nl> wrote:
> >
> > Hi Mikael,
> >
> > here's a very simple mwe for the label(textext()) issue. On page 1, the text "Word 1" should be drawn in position z1. On page 2, the same text in the same position should be visible, and the text "Mot 2" in position p2 should be added. And so on.
> >
> > \startMPinclusions
> >
> > picture p[];
> > path TheFrame ;
> > TheFrame := fullsquare scaled 5in ;
> >
> > z1 = (60,40);
> > z2 = (40,90);
> > z3 = (10,70);
> >
> > p1:=image(
> > label(textext("Word 1"), z1);
> > );
> >
> > p2:=image(
> > label(textext("Mot 2"), z2);
> > );
> >
> > p3:=image(
> > label(textext("Parola 3"), z3);
> > );
> >
> > \stopMPinclusions
> >
> > \starttext
> >
> > \dorecurse{3}{ % Frame
> > \startMPpage[pagestate=start]
> > currentime := #1 ;
> > % Just for learning :
> > draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> > draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> > for k=1 upto currentime: draw p[k]; endfor
> > setbounds currentpicture to TheFrame ;
> >
> > desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> > currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> >
> > \stopMPpage
> > }
> >
> > \stoptext
> >
> > On Dez. 2 2023, at 5:22 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
> >
> > Hi Emanuel,
> >
> > I am not sure I understand your question, and since you use fonts that
> > i do not have, I cannot test your example as is. But, maybe, if you
> > want to redraw a picture, you can do
> >
> > addto currentpicture also p1;
> >
> > where you want it.
> >
> > /Mikael
> >
> > PS For the text thing, I did not get it. Could one have a _very
> > simple_ example showing only that problem and no other problem?
> >
> > On Sat, Dec 2, 2023 at 12:58 PM fv leung <fvleung@gmail.com> wrote:
> > >
> > > You didn't specify the color of path A in p2 and p4. So it's drawn in black.
> > > The other issue, I can't help.
> > >
> > > Emanuel Han via ntg-context <ntg-context@ntg.nl> 於 2023年12月2日 週六 下午7:23寫道:
> > >>
> > >> So is there a way to circumvent these issues? Or an explanation for this behavior, so that I can try to find a solution by myself?
> > >>
> > >> Thanks
> > >> Emanuel
> > >>
> > >> On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> > >>
> > >> Dear Aditya and Fabrice,
> > >> thanks for your responses.
> > >>
> > >> I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
> > >> What is bizarre is that issues appear now that didn't appear before:
> > >>
> > >> Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.
> > >> textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.
> > >>
> > >> Adjusted mwe:
> > >>
> > >> \enableregime[utf] % enable unicoded input
> > >>
> > >> \definefontfamily [RomanFont] [rm] [calluna]
> > >>
> > >> \definefontfamily [KoreanFont] [rm] [applemyungjo]
> > >>
> > >> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
> > >>
> > >> \definefontfeature
> > >> [fea]
> > >> [mode=node,language=dflt,script=arab,
> > >> init=yes,
> > >> medi=yes,
> > >> fina=yes,
> > >> isol=yes,
> > >> calt=yes,
> > >> rlig=yes,
> > >> tlig=yes,
> > >> trep=yes,
> > >> curs=yes,
> > >> kern=yes,
> > >> mark=yes
> > >> ]
> > >>
> > >> \starttypescript [serif] [notonaskharabic]
> > >> \definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
> > >> \definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
> > >> \definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
> > >> \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
> > >> \stoptypescript
> > >>
> > >> \starttypescript [serif] [notonaskharabic]
> > >> \usetypescript[serif][fallback]
> > >> \definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
> > >> \definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
> > >> \definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
> > >> \definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
> > >> \stoptypescript
> > >>
> > >> \starttypescript [notonaskharabic]
> > >> \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
> > >> \stoptypescript
> > >>
> > >> \usetypescript[notonaskharabic]
> > >>
> > >> \setupbodyfont [RomanFont]
> > >>
> > >> \usecolors[crayola]
> > >>
> > >> \startMPinclusions
> > >>
> > >> picture p[];
> > >> path TheFrame ;
> > >> TheFrame := fullsquare scaled 5in ;
> > >>
> > >> z0 = (0,0);
> > >> z1 = (60,40);
> > >> z2 = (40,90);
> > >> z3 = (10,70);
> > >> z4 = (30,50);
> > >> z5 = (90,70);
> > >> z6 = (-10,70);
> > >>
> > >> path A; A = z0..z1..z2..z3..z4 ;
> > >> pair AStartPoint; AStartPoint = point 0 of A;
> > >> pair AEndPoint; AEndPoint = point 4 of A;
> > >> path B; B = z5..z6;
> > >> pair BStartPoint; BStartPoint = point 0 of B;
> > >> pair BEndPoint; BEndPoint = point 1 of B;
> > >> path C; C = AStartPoint..AEndPoint;
> > >>
> > >> p1:=image(
> > >> draw A withcolor red;
> > >> );
> > >>
> > >> p2:=image(draw A; label(lmt_outline [
> > >> text = "\JapaneseFont 日本語"
> > >> ], AEndPoint););
> > >>
> > >> p3:=image(
> > >> label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
> > >> );
> > >>
> > >> p4:=image(draw A; label(lmt_outline [
> > >> text = "\KoreanFont 한국어"
> > >> ], AStartPoint););
> > >>
> > >> p5:=image(
> > >> label(textext("bāng"), BEndPoint);
> > >> draw C withcolor green;
> > >> );
> > >>
> > >> p6:=image(
> > >> draw B withcolor blue;
> > >> );
> > >> \stopMPinclusions
> > >>
> > >> \starttext
> > >>
> > >> \dorecurse{6}{ % Frame
> > >> \setupMPpage[background=color, backgroundcolor=SpringGreen]
> > >> \startMPpage[pagestate=start]
> > >> currentime := #1 ;
> > >> % Just for learning :
> > >> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> > >> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> > >> for k=1 upto currentime: draw p[k]; endfor
> > >> setbounds currentpicture to TheFrame ;
> > >>
> > >> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> > >> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> > >>
> > >> \stopMPpage
> > >> }
> > >>
> > >> \stoptext
> > >> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
> > >>
> > >> On Mon, 27 Nov 2023, Fabrice L wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
> > >>
> > >> A very similar option is to pass a variable to a metapost drawing. This is what I use:
> > >>
> > >> https://adityam.github.io/context-blog/post/metapost-animation/
> > >>
> > >> It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> > >>
> > >> Aditya___________________________________________________________________________________
> > >> If your question is of interest to others as well, please add an entry to the Wiki!
> > >>
> > >> maillist : ntg-context@ntg.nl / 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
> > >> ___________________________________________________________________________________
> > >>
> > >> ___________________________________________________________________________________
> > >> If your question is of interest to others as well, please add an entry to the Wiki!
> > >>
> > >> maillist : ntg-context@ntg.nl / 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
> > >> ___________________________________________________________________________________
> > >>
> > >> ___________________________________________________________________________________
> > >> If your question is of interest to others as well, please add an entry to the Wiki!
> > >>
> > >> maillist : ntg-context@ntg.nl / 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
> > >> ___________________________________________________________________________________
> > >
> > > ___________________________________________________________________________________
> > > If your question is of interest to others as well, please add an entry to the Wiki!
> > >
> > > maillist : ntg-context@ntg.nl / 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
> > > ___________________________________________________________________________________
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / 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
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / 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
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________
>


[-- Attachment #1.2: Type: text/html, Size: 17528 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-12-02 17:08             ` Emanuel Han via ntg-context
  2023-12-02 18:46               ` Mikael Sundqvist
@ 2023-12-04 16:35               ` Fabrice L
  1 sibling, 0 replies; 12+ messages in thread
From: Fabrice L @ 2023-12-04 16:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 8884 bytes --]

Dear Emanuel,

> Le 2 déc. 2023 à 12:08, Emanuel Han via ntg-context <ntg-context@ntg.nl> a écrit :
> 
> Hi Mikael,
> 
> here's a very simple mwe for the label(textext()) issue. On page 1, the text "Word 1" should be drawn in position z1. On page 2, the same text in the same position should be visible, and the text "Mot 2" in position p2 should be added. And so on.
> 
> \startMPinclusions
> 
> picture p[];
>  path TheFrame ;
>  TheFrame := fullsquare scaled 5in ;
>  
>  z1 = (60,40);
>  z2 = (40,90); 
>  z3 = (10,70);
> 
> p1:=image(
>     label(textext("Word 1"), z1);
> );
> 
> p2:=image(
>     label(textext("Mot 2"), z2);
> );
> 
> p3:=image(
>     label(textext("Parola 3"), z3);
> );
> 
> \stopMPinclusions
> 
> \starttext
> 
> \dorecurse{3}{ % Frame
> \startMPpage[pagestate=start]  
>  currentime := #1 ;
>  % Just for learning :
>  draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
>  draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
>  for k=1 upto currentime: draw p[k]; endfor
>  setbounds currentpicture to TheFrame ;
> 
>  desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
>  currentpicture := currentpicture xysized (desiredformat ,desiredformat );
>  
> \stopMPpage
> }
> 
> \stoptext
> 
> On Dez. 2 2023, at 5:22 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
> Hi Emanuel,
> 
> I am not sure I understand your question, and since you use fonts that
> i do not have, I cannot test your example as is. But, maybe, if you
> want to redraw a picture, you can do
> 
> addto currentpicture also p1;
> 
> where you want it.
> 
> /Mikael
> 
> PS For the text thing, I did not get it. Could one have a _very
> simple_ example showing only that problem and no other problem?
> 
> On Sat, Dec 2, 2023 at 12:58 PM fv leung <fvleung@gmail.com> wrote:
> >
> > You didn't specify the color of path A in p2 and p4. So it's drawn in black.
> > The other issue, I can't help.
> >
> > Emanuel Han via ntg-context <ntg-context@ntg.nl> 於 2023年12月2日 週六 下午7:23寫道:
> >>
> >> So is there a way to circumvent these issues? Or an explanation for this behavior, so that I can try to find a solution by myself?
> >>
> >> Thanks
> >> Emanuel
> >>
> >> On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >>
> >> Dear Aditya and Fabrice,
> >> thanks for your responses.
> >>
> >> I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
> >> What is bizarre is that issues appear now that didn't appear before:
> >>
> >> Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.
> >> textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.
> >>
> >> Adjusted mwe:
> >>
> >> \enableregime[utf] % enable unicoded input
> >>
> >> \definefontfamily [RomanFont] [rm] [calluna]
> >>
> >> \definefontfamily [KoreanFont] [rm] [applemyungjo]
> >>
> >> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
> >>
> >> \definefontfeature
> >> [fea]
> >> [mode=node,language=dflt,script=arab,
> >> init=yes,
> >> medi=yes,
> >> fina=yes,
> >> isol=yes,
> >> calt=yes,
> >> rlig=yes,
> >> tlig=yes,
> >> trep=yes,
> >> curs=yes,
> >> kern=yes,
> >> mark=yes
> >> ]
> >>
> >> \starttypescript [serif] [notonaskharabic]
> >> \definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
> >> \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
> >> \stoptypescript
> >>
> >> \starttypescript [serif] [notonaskharabic]
> >> \usetypescript[serif][fallback]
> >> \definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
> >> \definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
> >> \definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
> >> \definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
> >> \stoptypescript
> >>
> >> \starttypescript [notonaskharabic]
> >> \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
> >> \stoptypescript
> >>
> >> \usetypescript[notonaskharabic]
> >>
> >> \setupbodyfont [RomanFont]
> >>
> >> \usecolors[crayola]
> >>
> >> \startMPinclusions
> >>
> >> picture p[];
> >> path TheFrame ;
> >> TheFrame := fullsquare scaled 5in ;
> >>
> >> z0 = (0,0);
> >> z1 = (60,40);
> >> z2 = (40,90);
> >> z3 = (10,70);
> >> z4 = (30,50);
> >> z5 = (90,70);
> >> z6 = (-10,70);
> >>
> >> path A; A = z0..z1..z2..z3..z4 ;
> >> pair AStartPoint; AStartPoint = point 0 of A;
> >> pair AEndPoint; AEndPoint = point 4 of A;
> >> path B; B = z5..z6;
> >> pair BStartPoint; BStartPoint = point 0 of B;
> >> pair BEndPoint; BEndPoint = point 1 of B;
> >> path C; C = AStartPoint..AEndPoint;
> >>
> >> p1:=image(
> >> draw A withcolor red;
> >> );
> >>
> >> p2:=image(draw A; label(lmt_outline [
> >> text = "\JapaneseFont 日本語"
> >> ], AEndPoint););
> >>
> >> p3:=image(
> >> label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
> >> );
> >>
> >> p4:=image(draw A; label(lmt_outline [
> >> text = "\KoreanFont 한국어"
> >> ], AStartPoint););
> >>
> >> p5:=image(
> >> label(textext("bāng"), BEndPoint);
> >> draw C withcolor green;
> >> );
> >>
> >> p6:=image(
> >> draw B withcolor blue;
> >> );
> >> \stopMPinclusions
> >>
> >> \starttext
> >>
> >> \dorecurse{6}{ % Frame
> >> \setupMPpage[background=color, backgroundcolor=SpringGreen]
> >> \startMPpage[pagestate=start]
> >> currentime := #1 ;
> >> % Just for learning :
> >> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> >> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> >> for k=1 upto currentime: draw p[k]; endfor
> >> setbounds currentpicture to TheFrame ;
> >>
> >> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> >> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> >>
> >> \stopMPpage
> >> }
> >>
> >> \stoptext
> >> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
> >>
> >> On Mon, 27 Nov 2023, Fabrice L wrote:
> >>
> >> > Hi,
> >> >
> >> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
> >>
> >> A very similar option is to pass a variable to a metapost drawing. This is what I use:
> >>
> >> https://adityam.github.io/context-blog/post/metapost-animation/
> >>
> >> It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> >>
> >> Aditya___________________________________________________________________________________
> >> If your question is of interest to others as well, please add an entry to the Wiki!
> >>
> _____________________________________________

I do not understand why your original code does not work, and I know Mickael has offered you a solution, but there is, just for curiosity,  another one to achieve your goal using \MPinclusions  :

% 8 < ———————————————

\starttext

\startMPinclusions

 path TheFrame ;
 TheFrame := fullsquare scaled 5in ;

 pair Coord[] ;
 string TheText[] ; 

 TheText[1] := "Word 1" ; Coord[1] := (60,40) ;
 TheText[2] := "Word 2" ; Coord[2] := (40,90) ;
 TheText[3] := "Word 3" ; Coord[3] := (10,70) ;

\stopMPinclusions

\dorecurse{3}{ % Frame
\startMPpage%[pagestate=start]  
 currentime := #1 ;

 % Just for learning :
 draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
 draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;

 for k=1 upto currentime: 
  draw textext(TheText[k]) shifted Coord[k] ;
  endfor ;
 
\stopMPpage
}

\stoptext
% 8 < ———————————————

Fabrice. 


[-- Attachment #1.2: Type: text/html, Size: 12584 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: multipage metapost output from ConTeXt
  2023-12-02 18:46               ` Mikael Sundqvist
  2023-12-02 22:51                 ` Emanuel Han via ntg-context
@ 2024-01-06 16:33                 ` Emanuel Han via ntg-context
  1 sibling, 0 replies; 12+ messages in thread
From: Emanuel Han via ntg-context @ 2024-01-06 16:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: mailing list for ConTeXt users, Emanuel Han


[-- Attachment #1.1: Type: text/plain, Size: 14509 bytes --]

Hi Mikael,

with the solution provided by you, I could work on my graphic which grows from page to page. So far I have already 28 pages. Now I would like to go back to the summed graphic of p1 to p21 and add the coming p29, p30 etc. to only that (that means contents of p22 to p28 should not be visible on pages 29 and forward).
I don't bother you with my code which is too long. Let's use the mwe provided by you (I added it here for convenience), where we have 3 pages. How can I have the content of p2 not be added on page 3 and forward?
\startuseMPgraphic{base}
picture p[];
path TheFrame ;
TheFrame := fullsquare scaled 5in ;
z1 = (60,40);
z2 = (40,90);
z3 = (10,70);

p1:=image(
label("Word 1", z1);
);

p2:=image(
label("Mot 2", z2);
);

p3:=image(
label("Parola 3", z3);
);

\stopuseMPgraphic
\starttext
\dorecurse{3}{ % Frame
\startMPpage[pagestate=start]
\includeMPgraphic{base}
currentime := #1 ;
% Just for learning :
draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in)
withcolor magenta ;
for k=1 upto currentime: addto currentpicture also p[k]; endfor
setbounds currentpicture to TheFrame ;

desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
currentpicture := currentpicture xysized (desiredformat ,desiredformat );
\stopMPpage
}

\stoptext
On Dez. 2 2023, at 7:46 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
> Hi,
>
> I don't know if \startMPinclusions \stopMPinclusions shall work with
> \startMPpage and \stopMPpage. In this case, one can use a separate
> graphics:
>
> \startuseMPgraphic{base}
> picture p[];
> path TheFrame ;
> TheFrame := fullsquare scaled 5in ;
> z1 = (60,40);
> z2 = (40,90);
> z3 = (10,70);
>
> p1:=image(
> label("Word 1", z1);
> );
>
> p2:=image(
> label("Mot 2", z2);
> );
>
> p3:=image(
> label("Parola 3", z3);
> );
>
> \stopuseMPgraphic
> \starttext
> \dorecurse{3}{ % Frame
> \startMPpage[pagestate=start]
> \includeMPgraphic{base}
> currentime := #1 ;
> % Just for learning :
> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in)
> withcolor magenta ;
> for k=1 upto currentime: addto currentpicture also p[k]; endfor
> setbounds currentpicture to TheFrame ;
>
> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> \stopMPpage
> }
>
> \stoptext
> /Mikael
> On Sat, Dec 2, 2023 at 6:14 PM Emanuel Han via ntg-context
> <ntg-context@ntg.nl> wrote:
> >
> > Hi Mikael,
> >
> > here's a very simple mwe for the label(textext()) issue. On page 1, the text "Word 1" should be drawn in position z1. On page 2, the same text in the same position should be visible, and the text "Mot 2" in position p2 should be added. And so on.
> >
> > \startMPinclusions
> >
> > picture p[];
> > path TheFrame ;
> > TheFrame := fullsquare scaled 5in ;
> >
> > z1 = (60,40);
> > z2 = (40,90);
> > z3 = (10,70);
> >
> > p1:=image(
> > label(textext("Word 1"), z1);
> > );
> >
> > p2:=image(
> > label(textext("Mot 2"), z2);
> > );
> >
> > p3:=image(
> > label(textext("Parola 3"), z3);
> > );
> >
> > \stopMPinclusions
> >
> > \starttext
> >
> > \dorecurse{3}{ % Frame
> > \startMPpage[pagestate=start]
> > currentime := #1 ;
> > % Just for learning :
> > draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> > draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> > for k=1 upto currentime: draw p[k]; endfor
> > setbounds currentpicture to TheFrame ;
> >
> > desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> > currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> >
> > \stopMPpage
> > }
> >
> > \stoptext
> >
> > On Dez. 2 2023, at 5:22 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
> >
> > Hi Emanuel,
> >
> > I am not sure I understand your question, and since you use fonts that
> > i do not have, I cannot test your example as is. But, maybe, if you
> > want to redraw a picture, you can do
> >
> > addto currentpicture also p1;
> >
> > where you want it.
> >
> > /Mikael
> >
> > PS For the text thing, I did not get it. Could one have a _very
> > simple_ example showing only that problem and no other problem?
> >
> > On Sat, Dec 2, 2023 at 12:58 PM fv leung <fvleung@gmail.com> wrote:
> > >
> > > You didn't specify the color of path A in p2 and p4. So it's drawn in black.
> > > The other issue, I can't help.
> > >
> > > Emanuel Han via ntg-context <ntg-context@ntg.nl> 於 2023年12月2日 週六 下午7:23寫道:
> > >>
> > >> So is there a way to circumvent these issues? Or an explanation for this behavior, so that I can try to find a solution by myself?
> > >>
> > >> Thanks
> > >> Emanuel
> > >>
> > >> On Nov. 29 2023, at 12:25 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> > >>
> > >> Dear Aditya and Fabrice,
> > >> thanks for your responses.
> > >>
> > >> I included some of Fabrice's code into mine for testing purpose, and indeed the multipage works now.
> > >> What is bizarre is that issues appear now that didn't appear before:
> > >>
> > >> Path A is drawn with color red on page 1, and in color black on all following pages, while it should stay red.
> > >> textext(<text>, <pair>) is overwriting <text> with "T="&decimal(currentime) which has been used previously in textext() before the for k=1 endfor loop. This overwriting happens only for the first textext() which occurs inside the for k=1 endfor loop. All other textext() inside the for k=1 endfor loop are not drawn at all. If the line « draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ; » is commented out, the first textext() inside the for k=1 endfor loop is not drawn neither. It must be an issue with textext(), because when I replace textext() by lmt_outline[], the text is drawn.
> > >>
> > >> Adjusted mwe:
> > >>
> > >> \enableregime[utf] % enable unicoded input
> > >>
> > >> \definefontfamily [RomanFont] [rm] [calluna]
> > >>
> > >> \definefontfamily [KoreanFont] [rm] [applemyungjo]
> > >>
> > >> \definefontfamily [JapaneseFont] [rm] [hannotatesc]
> > >>
> > >> \definefontfeature
> > >> [fea]
> > >> [mode=node,language=dflt,script=arab,
> > >> init=yes,
> > >> medi=yes,
> > >> fina=yes,
> > >> isol=yes,
> > >> calt=yes,
> > >> rlig=yes,
> > >> tlig=yes,
> > >> trep=yes,
> > >> curs=yes,
> > >> kern=yes,
> > >> mark=yes
> > >> ]
> > >>
> > >> \starttypescript [serif] [notonaskharabic]
> > >> \definefontsynonym [notonaskharabic-Light] [name:notonaskharabic] [features=fea]
> > >> \definefontsynonym [notonaskharabic-Bold] [name:notonaskharabic] [features=fea]
> > >> \definefontsynonym [notonaskharabic-Italic] [name:notonaskharabic] [features=fea]
> > >> \definefontsynonym [notonaskharabic-Bold-Italic] [name:notonaskharabic] [features=fea]
> > >> \stoptypescript
> > >>
> > >> \starttypescript [serif] [notonaskharabic]
> > >> \usetypescript[serif][fallback]
> > >> \definefontsynonym [Serif] [notonaskharabic-Light] [features=fea]
> > >> \definefontsynonym [SerifItalic] [notonaskharabic-Italic] [features=fea]
> > >> \definefontsynonym [SerifBold] [notonaskharabic-Bold] [features=fea]
> > >> \definefontsynonym [SerifBoldItalic] [notonaskharabic-Bold-Italic] [features=fea]
> > >> \stoptypescript
> > >>
> > >> \starttypescript [notonaskharabic]
> > >> \definetypeface [notonaskharabic] [rm] [serif] [notonaskharabic] [default]
> > >> \stoptypescript
> > >>
> > >> \usetypescript[notonaskharabic]
> > >>
> > >> \setupbodyfont [RomanFont]
> > >>
> > >> \usecolors[crayola]
> > >>
> > >> \startMPinclusions
> > >>
> > >> picture p[];
> > >> path TheFrame ;
> > >> TheFrame := fullsquare scaled 5in ;
> > >>
> > >> z0 = (0,0);
> > >> z1 = (60,40);
> > >> z2 = (40,90);
> > >> z3 = (10,70);
> > >> z4 = (30,50);
> > >> z5 = (90,70);
> > >> z6 = (-10,70);
> > >>
> > >> path A; A = z0..z1..z2..z3..z4 ;
> > >> pair AStartPoint; AStartPoint = point 0 of A;
> > >> pair AEndPoint; AEndPoint = point 4 of A;
> > >> path B; B = z5..z6;
> > >> pair BStartPoint; BStartPoint = point 0 of B;
> > >> pair BEndPoint; BEndPoint = point 1 of B;
> > >> path C; C = AStartPoint..AEndPoint;
> > >>
> > >> p1:=image(
> > >> draw A withcolor red;
> > >> );
> > >>
> > >> p2:=image(draw A; label(lmt_outline [
> > >> text = "\JapaneseFont 日本語"
> > >> ], AEndPoint););
> > >>
> > >> p3:=image(
> > >> label(textext("\notonaskharabic \textdir TRT دانگ") scaled 1.2, BStartPoint);
> > >> );
> > >>
> > >> p4:=image(draw A; label(lmt_outline [
> > >> text = "\KoreanFont 한국어"
> > >> ], AStartPoint););
> > >>
> > >> p5:=image(
> > >> label(textext("bāng"), BEndPoint);
> > >> draw C withcolor green;
> > >> );
> > >>
> > >> p6:=image(
> > >> draw B withcolor blue;
> > >> );
> > >> \stopMPinclusions
> > >>
> > >> \starttext
> > >>
> > >> \dorecurse{6}{ % Frame
> > >> \setupMPpage[background=color, backgroundcolor=SpringGreen]
> > >> \startMPpage[pagestate=start]
> > >> currentime := #1 ;
> > >> % Just for learning :
> > >> draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
> > >> draw textext("T="&decimal(currentime)) scaled 2 shifted(0,2in) withcolor magenta ;
> > >> for k=1 upto currentime: draw p[k]; endfor
> > >> setbounds currentpicture to TheFrame ;
> > >>
> > >> desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
> > >> currentpicture := currentpicture xysized (desiredformat ,desiredformat );
> > >>
> > >> \stopMPpage
> > >> }
> > >>
> > >> \stoptext
> > >> On Nov. 27 2023, at 11:25 pm, Aditya Mahajan <adityam@umich.edu> wrote:
> > >>
> > >> On Mon, 27 Nov 2023, Fabrice L wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > It is fun fact very easy to do. You just use \startMPpage (…) \stopMPpage multiple times. Here is an example which build an animation of a particle moving according to a Brownian motion.
> > >>
> > >> A very similar option is to pass a variable to a metapost drawing. This is what I use:
> > >>
> > >> https://adityam.github.io/context-blog/post/metapost-animation/
> > >>
> > >> It only works when viewed in acrobat, you can just comment out the animation part and wrap it in \startTEXpage .. \stopTEXpage to get multi-page animation.
> > >>
> > >> Aditya___________________________________________________________________________________
> > >> If your question is of interest to others as well, please add an entry to the Wiki!
> > >>
> > >> maillist : ntg-context@ntg.nl / 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
> > >> ___________________________________________________________________________________
> > >>
> > >> ___________________________________________________________________________________
> > >> If your question is of interest to others as well, please add an entry to the Wiki!
> > >>
> > >> maillist : ntg-context@ntg.nl / 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
> > >> ___________________________________________________________________________________
> > >>
> > >> ___________________________________________________________________________________
> > >> If your question is of interest to others as well, please add an entry to the Wiki!
> > >>
> > >> maillist : ntg-context@ntg.nl / 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
> > >> ___________________________________________________________________________________
> > >
> > > ___________________________________________________________________________________
> > > If your question is of interest to others as well, please add an entry to the Wiki!
> > >
> > > maillist : ntg-context@ntg.nl / 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
> > > ___________________________________________________________________________________
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / 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
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / 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
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / 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
> ___________________________________________________________________________________
>


[-- Attachment #1.2: Type: text/html, Size: 19232 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

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

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-01-06 16:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-27 18:49 [NTG-context] multipage metapost output from ConTeXt Emanuel Han via ntg-context
2023-11-27 19:56 ` [NTG-context] " Fabrice L
2023-11-27 22:25   ` Aditya Mahajan
2023-11-29 11:25     ` Emanuel Han via ntg-context
2023-12-02 11:22       ` Emanuel Han via ntg-context
2023-12-02 11:54         ` fv leung
2023-12-02 16:22           ` Mikael Sundqvist
2023-12-02 17:08             ` Emanuel Han via ntg-context
2023-12-02 18:46               ` Mikael Sundqvist
2023-12-02 22:51                 ` Emanuel Han via ntg-context
2024-01-06 16:33                 ` Emanuel Han via ntg-context
2023-12-04 16:35               ` Fabrice L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).