Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use context.useMPcode instead of tex.sprint("useMPgraphic") #1

Open
GoogleCodeExporter opened this issue Sep 24, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

See NTG-context mailing list: metapost and lua

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

----------------------------------------------

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

---------------------

Original issue reported on code.google.com by [email protected] on 6 Aug 2010 at 8:59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant