ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: ntg-context@ntg.nl
Subject: Re: Passing data back and forth between metapost and lua
Date: Sun, 19 Mar 2017 20:02:45 +0100	[thread overview]
Message-ID: <ce678c84-e581-f667-8d5c-8d5e88ac7e8c@wxs.nl> (raw)
In-Reply-To: <alpine.OSX.2.02.1703191128200.23375@nqv-znpobbx>

On 3/19/2017 7:29 PM, Aditya Mahajan wrote:
> On Sun, 19 Mar 2017, Aditya Mahajan wrote:
>
>> On Tue, 20 Dec 2016, Alan Braslau wrote:
>>
>>> On Mon, 19 Dec 2016 08:19:25 -0800
>>> Aditya Mahajan <adityam@umich.edu> wrote:
>>>
>>>> The ability to pass parameters to metapost has been around since the
>>>> beginning. See the metafun manual for details (search for MPvar).
>>>
>>> Hans has developed tools making it quite easy to pass data back and
>>> forth between MetaPost and lua. This is quite efficient, and it is
>>> being used more and more in the development of macro functionality.
>>
>> I finally need to write a macro where I want to pass data from lua to
>> metapost. I could not find an example in the source code showing this.
>> Can someone show a basic example of how lua-metapost interface works
>> or point me to the appropriate files in the source.
>
> Found some information in the CLD manual. That is sufficient for the
> task at hand for me. But a pointer to a more detailed source will be
> welcome.

real low level

\starttext

\startluacode

     document.mydata = { foo = "foo", bar = 123 }

\stopluacode

\startMPcode

     draw fullcircle scaled lua("mp.print(document.mydata.bar)") ;
     draw textext (lua("mp.quoted(document.mydata.foo)")) ;

\stopMPcode

\stoptext

i'll mail you the new chapter in the metafun manual

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

      reply	other threads:[~2017-03-19 19:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19  7:41 Asymptote or Metapost and ConTeXt parameters Jaroslav Hajtmar
2016-12-19  9:10 ` Fabrice Couvreur
2016-12-19  9:43   ` Hans Hagen
2016-12-19 16:19 ` Aditya Mahajan
2016-12-20 10:34   ` Jaroslav Hajtmar
2016-12-22  4:49     ` Aditya Mahajan
2016-12-23  8:02       ` Jaroslav Hajtmar
2016-12-23 19:22         ` Aditya Mahajan
2016-12-23 20:28           ` Hans Hagen
2016-12-24  2:55           ` Jaroslav Hajtmar
2016-12-24  3:05             ` Aditya Mahajan
2016-12-20 22:14   ` Alan Braslau
2016-12-21  7:49     ` Aditya Mahajan
2017-03-19 18:01     ` Passing data back and forth between metapost and lua Aditya Mahajan
2017-03-19 18:29       ` Aditya Mahajan
2017-03-19 19:02         ` Hans Hagen [this message]

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=ce678c84-e581-f667-8d5c-8d5e88ac7e8c@wxs.nl \
    --to=pragma@wxs.nl \
    --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).