* Can I share METAPOST vardefs over multiple pages?
@ 2020-03-13 11:53 Gerben Wierda
2020-03-13 12:24 ` Taco Hoekwater
0 siblings, 1 reply; 8+ messages in thread
From: Gerben Wierda @ 2020-03-13 11:53 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 788 bytes --]
Suppose I have this code:
\startMPpage
vardef MyShape(expr w, h) =
save pth; path pth ;
save pic; picture pic;
pth = fullsquare xysized (w, h);
pic := image (
draw pth;
% all kind of stuff here
);
setbounds pic to pth;
pic
enddef ;
picture s ; s := MyShape(4cm, 2cm);
draw s;
drawdot center leftboundary s withpen pencircle scaled 2 withcolor green;
drawdot center rightboundary s withpen pencircle scaled 2 withcolor blue;
drawdot point .25 along topboundary s withpen pencircle scaled 2 withcolor yellow;
drawdot .25[llcorner s, lrcorner s] withpen pencircle scaled 2 withcolor magenta;
drawdot origin withpen pencircle scaled 2 withcolor red;
\stopMPpage
Can I reuse that varied across follow-up MPPages?
G
[-- Attachment #1.2: Type: text/html, Size: 1723 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can I share METAPOST vardefs over multiple pages?
2020-03-13 11:53 Can I share METAPOST vardefs over multiple pages? Gerben Wierda
@ 2020-03-13 12:24 ` Taco Hoekwater
2020-03-13 13:33 ` Aditya Mahajan
2020-03-13 13:47 ` Gerben Wierda
0 siblings, 2 replies; 8+ messages in thread
From: Taco Hoekwater @ 2020-03-13 12:24 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi,
> On 13 Mar 2020, at 12:53, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:
>
> Suppose I have this code:
>
>
> Can I reuse that varied across follow-up MPPages?
Sure, put the vardef inside \startMPinclusions:
\startMPinclusions
vardef MyShape(expr w, h) =
...
enddef ;
\stopMPinclusions
\startMPpage
picture s ; s := MyShape(4cm, 2cm);
draw s;
. . .
\stopMPpage
\startMPpage
picture s ; s := MyShape(8cm, 4cm);
draw s;
. . .
\stopMPpage
Taco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can I share METAPOST vardefs over multiple pages?
2020-03-13 12:24 ` Taco Hoekwater
@ 2020-03-13 13:33 ` Aditya Mahajan
2020-03-13 13:59 ` Hans Hagen
2020-03-13 13:47 ` Gerben Wierda
1 sibling, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2020-03-13 13:33 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Fri, 13 Mar 2020, Taco Hoekwater wrote:
> Hi,
>
>
>
>> On 13 Mar 2020, at 12:53, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:
>>
>> Suppose I have this code:
>>
>>
>> Can I reuse that varied across follow-up MPPages?
>
> Sure, put the vardef inside \startMPinclusions:
or \startMPdefinitions ... \stopMPdefinitions (don't remember what is the
difference between inclusions and definitions, now).
Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can I share METAPOST vardefs over multiple pages?
2020-03-13 12:24 ` Taco Hoekwater
2020-03-13 13:33 ` Aditya Mahajan
@ 2020-03-13 13:47 ` Gerben Wierda
1 sibling, 0 replies; 8+ messages in thread
From: Gerben Wierda @ 2020-03-13 13:47 UTC (permalink / raw)
To: mailing list for ConTeXt users
Thank you. And if I want these in a separate file, what is the correct way to include them?
> On 13 Mar 2020, at 13:24, Taco Hoekwater <taco@elvenkind.com> wrote:
>
> Hi,
>
>
>
>> On 13 Mar 2020, at 12:53, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:
>>
>> Suppose I have this code:
>>
>>
>> Can I reuse that varied across follow-up MPPages?
>
> Sure, put the vardef inside \startMPinclusions:
>
> \startMPinclusions
> vardef MyShape(expr w, h) =
> ...
> enddef ;
> \stopMPinclusions
> \startMPpage
> picture s ; s := MyShape(4cm, 2cm);
>
> draw s;
> . . .
> \stopMPpage
>
> \startMPpage
> picture s ; s := MyShape(8cm, 4cm);
>
> draw s;
> . . .
> \stopMPpage
>
>
> Taco
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : http://www.pragma-ade.nl / http://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can I share METAPOST vardefs over multiple pages?
2020-03-13 13:33 ` Aditya Mahajan
@ 2020-03-13 13:59 ` Hans Hagen
2020-03-14 12:20 ` Gerben Wierda
2020-03-16 10:12 ` Gerben Wierda
0 siblings, 2 replies; 8+ messages in thread
From: Hans Hagen @ 2020-03-13 13:59 UTC (permalink / raw)
To: mailing list for ConTeXt users, Aditya Mahajan
On 3/13/2020 2:33 PM, Aditya Mahajan wrote:
> On Fri, 13 Mar 2020, Taco Hoekwater wrote:
>
>> Hi,
>>
>>
>>
>>> On 13 Mar 2020, at 12:53, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:
>>>
>>> Suppose I have this code:
>>>
>>>
>>> Can I reuse that varied across follow-up MPPages?
>>
>> Sure, put the vardef inside \startMPinclusions:
>
> or \startMPdefinitions ... \stopMPdefinitions (don't remember what is
> the difference between inclusions and definitions, now).
definitions: once
inclusions : every time
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can I share METAPOST vardefs over multiple pages?
2020-03-13 13:59 ` Hans Hagen
@ 2020-03-14 12:20 ` Gerben Wierda
2020-03-16 10:12 ` Gerben Wierda
1 sibling, 0 replies; 8+ messages in thread
From: Gerben Wierda @ 2020-03-14 12:20 UTC (permalink / raw)
To: mailing list for ConTeXt users
> On 13 Mar 2020, at 14:59, Hans Hagen <j.hagen@xs4all.nl> wrote:
>
> On 3/13/2020 2:33 PM, Aditya Mahajan wrote:
>> On Fri, 13 Mar 2020, Taco Hoekwater wrote:
>>> Hi,
>>>
>>>
>>>
>>>> On 13 Mar 2020, at 12:53, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:
>>>>
>>>> Suppose I have this code:
>>>>
>>>>
>>>> Can I reuse that varied across follow-up MPPages?
>>>
>>> Sure, put the vardef inside \startMPinclusions:
>> or \startMPdefinitions ... \stopMPdefinitions (don't remember what is the difference between inclusions and definitions, now).
> definitions: once
> inclusions : every time
That is not quite clear to me (ambiguous because of a lack of experience).
Does ‘once’ mean, valid in just one page or valid in all following pages?
G
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can I share METAPOST vardefs over multiple pages?
2020-03-13 13:59 ` Hans Hagen
2020-03-14 12:20 ` Gerben Wierda
@ 2020-03-16 10:12 ` Gerben Wierda
2020-03-16 22:10 ` Aditya Mahajan
1 sibling, 1 reply; 8+ messages in thread
From: Gerben Wierda @ 2020-03-16 10:12 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 3063 bytes --]
This worked when I was just doing METAPOST. Now, I am using my lua code to produce the METAPOST code that produces the pictures. And the picture itself is put in a file for METAPOST as follows:
File test4-mplib-run-001.mp:
% begin graphic: n=0
; beginfig(1) ; defaultfont:="name:dejavuserif*default"; CurrentLayout:="article"; def OverlayLineColor=black enddef; def OverlayColor =black enddef; ;picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=273.000; y:=253.000; w:=133.000; h:=53.000;pic := Function( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=380.000; y:=133.000; w:=133.000; h:=53.000;pic := Service( w, h, typeString) shifted (x, -y); draw pic;path p; p := (200.000,-227.000)--(333.000,-227.000)--(333.000,-273.000); draw p;path p; p := (393.000,-253.000)--(393.000,-180.000); draw p;;; endfig ;
% end graphic
This apparently is tried to get run through METAPOST separately and that clearly doesn’t work, because ApplicationComponentLogo isn’t defined. This is the result of the following setup:
\starttext
\startMPdefinitions (or inclusions, no difference)
% ApplicationComponentLogo is defined here with a vardef
\stopMPdefinitions
\ctxlua{foo(“filename”)} % produces a series of
% context.startMPpage { instance = "doublefun” }
% several of:
% context( METAPOST statements in a string)
% context.stopMPpage()
\stoptext
How do I get my MPdefinitions available in those METAPOST runs?
G
> On 13 Mar 2020, at 14:59, Hans Hagen <j.hagen@xs4all.nl> wrote:
>
> On 3/13/2020 2:33 PM, Aditya Mahajan wrote:
>> On Fri, 13 Mar 2020, Taco Hoekwater wrote:
>>> Hi,
>>>
>>>
>>>
>>>> On 13 Mar 2020, at 12:53, Gerben Wierda <Gerben.Wierda@rna.nl> wrote:
>>>>
>>>> Suppose I have this code:
>>>>
>>>>
>>>> Can I reuse that varied across follow-up MPPages?
>>>
>>> Sure, put the vardef inside \startMPinclusions:
>> or \startMPdefinitions ... \stopMPdefinitions (don't remember what is the difference between inclusions and definitions, now).
> definitions: once
> inclusions : every time
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : http://www.pragma-ade.nl / http://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 7014 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can I share METAPOST vardefs over multiple pages?
2020-03-16 10:12 ` Gerben Wierda
@ 2020-03-16 22:10 ` Aditya Mahajan
0 siblings, 0 replies; 8+ messages in thread
From: Aditya Mahajan @ 2020-03-16 22:10 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 1848 bytes --]
On Mon, 16 Mar 2020, Gerben Wierda wrote:
> This worked when I was just doing METAPOST. Now, I am using my lua code to produce the METAPOST code that produces the pictures. And the picture itself is put in a file for METAPOST as follows:
>
> File test4-mplib-run-001.mp:
>
> % begin graphic: n=0
>
> ; beginfig(1) ; defaultfont:="name:dejavuserif*default"; CurrentLayout:="article"; def OverlayLineColor=black enddef; def OverlayColor =black enddef; ;picture pic; x:=80.000; y:=200.000; w:=133.000; h:=53.000;pic := ApplicationComponentLogo( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=273.000; y:=253.000; w:=133.000; h:=53.000;pic := Function( w, h, typeString) shifted (x, -y); draw pic;picture pic; x:=380.000; y:=133.000; w:=133.000; h:=53.000;pic := Service( w, h, typeString) shifted (x, -y); draw pic;path p; p := (200.000,-227.000)--(333.000,-227.000)--(333.000,-273.000); draw p;path p; p := (393.000,-253.000)--(393.000,-180.000); draw p;;; endfig ;
> % end graphic
>
> This apparently is tried to get run through METAPOST separately and that clearly doesn’t work, because ApplicationComponentLogo isn’t defined. This is the result of the following setup:
>
> \starttext
> \startMPdefinitions (or inclusions, no difference)
> % ApplicationComponentLogo is defined here with a vardef
> \stopMPdefinitions
> \ctxlua{foo(“filename”)} % produces a series of
> % context.startMPpage { instance = "doublefun” }
> % several of:
> % context( METAPOST statements in a string)
> % context.stopMPpage()
> \stoptext
>
> How do I get my MPdefinitions available in those METAPOST runs?
Since you are using \startMPpage[instace=doublefun], you need to do the
definitions for doublefun instance: so use
\startMPdefinitions{doublefun}
...
\stopMPdefinitions
Aditya
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-03-16 22:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 11:53 Can I share METAPOST vardefs over multiple pages? Gerben Wierda
2020-03-13 12:24 ` Taco Hoekwater
2020-03-13 13:33 ` Aditya Mahajan
2020-03-13 13:59 ` Hans Hagen
2020-03-14 12:20 ` Gerben Wierda
2020-03-16 10:12 ` Gerben Wierda
2020-03-16 22:10 ` Aditya Mahajan
2020-03-13 13:47 ` Gerben Wierda
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).