ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Can I share METAPOST vardefs over multiple pages?
Date: Mon, 16 Mar 2020 18:10:20 -0400 (EDT)	[thread overview]
Message-ID: <nycvar.YAK.7.77.849.2003161807431.3177@nqv-guvaxcnq> (raw)
In-Reply-To: <916B32A2-2C23-4BF3-BD82-0FA03B30770D@rna.nl>

[-- 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
___________________________________________________________________________________

  reply	other threads:[~2020-03-16 22:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13 11:53 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 [this message]
2020-03-13 13:47   ` Gerben Wierda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=nycvar.YAK.7.77.849.2003161807431.3177@nqv-guvaxcnq \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).