ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* metapost and lua
@ 2010-08-05 22:32 Philipp Gesang
  2010-08-05 22:55 ` Hans Hagen
  2010-08-06 11:34 ` Hans Hagen
  0 siblings, 2 replies; 6+ messages in thread
From: Philipp Gesang @ 2010-08-05 22:32 UTC (permalink / raw)
  To: ntg-context


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

Hi all!

[1]     Is there a Lua interface for metapost? I'm thinking of something
        like cld is for TeX here. All I figured out so far is how to
        generate mp code (as strings) in Lua and then having it
        processed by mplib, but as the metafun manual is from 2002 and
        with context you never know how far it is ahead of your dreams …

[1a]    If not [1], then: will there ever be something like this?

[2]     There's an example for “metapost.process()” in mlib-ctx.mkiv but
        I can't get it to work. I simply copypasted it as follows:

···8<··········································································

\starttext
\startluacode
mpgraphic = [[
    for i=1 upto 1000 :
        beginfig(0);
            draw halfcircle scaled 1cm withcolor green ;
            picture p ; p := "oeps" infont defaultfont scaled .75 rotated 45 ;
            p := p shifted - (xpart center p,0) ;
            draw p ; draw boundingbox p ;
        endfig ;
        beginfig(0);
            draw halfcircle scaled 1cm dashed evenly withcolor green ;
        endfig ;
        beginfig(0);
            pickup pencircle xscaled .5mm yscaled .25mm  rotated 45 ;
            draw halfcircle scaled 1cm withcolor red ;
        endfig ;
        beginfig(0);
            draw halfcircle scaled 1cm ;
        endfig ;
        beginfig(0);
           pickup pencircle xscaled .5mm yscaled .25mm  rotated 45 ;
            for k:=1 upto 10 :
                draw halfcircle scaled uniformdeviate(1cm) withcolor (red/(k/4)) ;
            endfor ;
        endfig ;                                                                                   
    endfor ;
]]
metapost.process(metapost.format("metafun"),mpgraphic)
\stopluacode

\stoptext

···8<··········································································

        This fails in mlib-run.lua at line 324. (Same with all my other
        tries, but I assume code from the context sources has a much
        higher probability of being valid.) Do I miss something critical?

Thanks for your help,

Philipp

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: metapost and lua
  2010-08-05 22:32 metapost and lua Philipp Gesang
@ 2010-08-05 22:55 ` Hans Hagen
  2010-08-06 11:34 ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2010-08-05 22:55 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Philipp Gesang

On 6-8-2010 12:32, Philipp Gesang wrote:

> [1a]    If not [1], then: will there ever be something like this?

it's on my agenda to look into this

> [2]     There's an example for “metapost.process()” in mlib-ctx.mkiv but
>          I can't get it to work. I simply copypasted it as follows:

i have no time now, but remind me to make an example

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: metapost and lua
  2010-08-05 22:32 metapost and lua Philipp Gesang
  2010-08-05 22:55 ` Hans Hagen
@ 2010-08-06 11:34 ` Hans Hagen
  2010-08-06 11:44   ` Hans Hagen
  2010-08-06 12:17   ` Philipp Gesang
  1 sibling, 2 replies; 6+ messages in thread
From: Hans Hagen @ 2010-08-06 11:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Philipp Gesang

On 6-8-2010 12:32, Philipp Gesang wrote:
> Hi all!
>
> [1]     Is there a Lua interface for metapost? I'm thinking of something
>          like cld is for TeX here. All I figured out so far is how to
>          generate mp code (as strings) in Lua and then having it
>          processed by mplib, but as the metafun manual is from 2002 and
>          with context you never know how far it is ahead of your dreams …
>
> [1a]    If not [1], then: will there ever be something like this?
>
> [2]     There's an example for “metapost.process()” in mlib-ctx.mkiv but
>          I can't get it to work. I simply copypasted it as follows:
>
> ···8<··········································································
>
> \starttext
> \startluacode
> mpgraphic = [[
>      for i=1 upto 1000 :
>          beginfig(0);
>              draw halfcircle scaled 1cm withcolor green ;
>              picture p ; p := "oeps" infont defaultfont scaled .75 rotated 45 ;
>              p := p shifted - (xpart center p,0) ;
>              draw p ; draw boundingbox p ;
>          endfig ;
>          beginfig(0);
>              draw halfcircle scaled 1cm dashed evenly withcolor green ;
>          endfig ;
>          beginfig(0);
>              pickup pencircle xscaled .5mm yscaled .25mm  rotated 45 ;
>              draw halfcircle scaled 1cm withcolor red ;
>          endfig ;
>          beginfig(0);
>              draw halfcircle scaled 1cm ;
>          endfig ;
>          beginfig(0);
>             pickup pencircle xscaled .5mm yscaled .25mm  rotated 45 ;
>              for k:=1 upto 10 :
>                  draw halfcircle scaled uniformdeviate(1cm) withcolor (red/(k/4)) ;
>              endfor ;
>          endfig ;
>      endfor ;
> ]]
> metapost.process(metapost.format("metafun"),mpgraphic)
> \stopluacode
>
> \stoptext

how about:

\starttext

\startluacode
context.startMPcode()
context("draw fullcircle scaled 10cm;")
context.stopMPcode()

context.resetMPdrawing()

context.startMPdrawing()
context("fill fullcircle scaled 10cm;")
context.stopMPdrawing()

for i=1,100,5 do
     context.startMPdrawing()
     context("draw fullcircle scaled " ..i .. "mm withcolor white;")
     context.stopMPdrawing()
end

context.MPdrawingdonetrue()

context.getMPdrawing()
\stopluacode

\stoptext


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: metapost and lua
  2010-08-06 11:34 ` Hans Hagen
@ 2010-08-06 11:44   ` Hans Hagen
  2010-08-06 12:20     ` Philipp Gesang
  2010-08-06 12:17   ` Philipp Gesang
  1 sibling, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2010-08-06 11:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Philipp Gesang

Hi,

I've added \MPdrawing and \MPcode so that less calls are needed

for i=1,100,5 do
     context.MPdrawing("draw fullsquare scaled " ..i .. "mm withcolor 
white;")
end

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: metapost and lua
  2010-08-06 11:34 ` Hans Hagen
  2010-08-06 11:44   ` Hans Hagen
@ 2010-08-06 12:17   ` Philipp Gesang
  1 sibling, 0 replies; 6+ messages in thread
From: Philipp Gesang @ 2010-08-06 12:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

On 2010-08-06 <13:34:20>, Hans Hagen wrote:
> how about:
> 
> \starttext
> 
> \startluacode
> context.startMPcode()
> context("draw fullcircle scaled 10cm;")
> context.stopMPcode()
> 
> context.resetMPdrawing()
> 
> context.startMPdrawing()
> context("fill fullcircle scaled 10cm;")
> context.stopMPdrawing()
> 
> for i=1,100,5 do
>     context.startMPdrawing()
>     context("draw fullcircle scaled " ..i .. "mm withcolor white;")
>     context.stopMPdrawing()
> end
> 
> context.MPdrawingdonetrue()
> 
> context.getMPdrawing()
> \stopluacode
> 
> \stoptext

That's more or less what I'm doing right now; I was being curious about
the “metapost.process(etc)” function, especially concerning the first
argument: “mpx” -- what could be a valid format identifier besides
"metafun"? Why does it fail on the otherwise sound example from
mlib-ctx.mkiv? It's nothing urgent, just plain curiosity.

Philipp


-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: metapost and lua
  2010-08-06 11:44   ` Hans Hagen
@ 2010-08-06 12:20     ` Philipp Gesang
  0 siblings, 0 replies; 6+ messages in thread
From: Philipp Gesang @ 2010-08-06 12:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

On 2010-08-06 <13:44:14>, Hans Hagen wrote:
> Hi,
> 
> I've added \MPdrawing and \MPcode so that less calls are needed

Great! Many thanks for this. 
Philipp

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2010-08-06 12:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-05 22:32 metapost and lua Philipp Gesang
2010-08-05 22:55 ` Hans Hagen
2010-08-06 11:34 ` Hans Hagen
2010-08-06 11:44   ` Hans Hagen
2010-08-06 12:20     ` Philipp Gesang
2010-08-06 12:17   ` Philipp Gesang

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