diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
commit | 57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch) | |
tree | 1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/tex/context/base/mlib-ctx.lua | |
parent | 6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff) |
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mlib-ctx.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mlib-ctx.lua | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/context/base/mlib-ctx.lua b/Master/texmf-dist/tex/context/base/mlib-ctx.lua index 821b702c601..cc5682e6fdc 100644 --- a/Master/texmf-dist/tex/context/base/mlib-ctx.lua +++ b/Master/texmf-dist/tex/context/base/mlib-ctx.lua @@ -1,6 +1,6 @@ if not modules then modules = { } end modules ['mlib-ctx'] = { version = 1.001, - comment = "companion to mlib-ctx.tex", + comment = "companion to mlib-ctx.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files", @@ -11,12 +11,32 @@ if not modules then modules = { } end modules ['mlib-ctx'] = { local format, join = string.format, table.concat local sprint = tex.sprint +local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming + metapost = metapost or {} metapost.defaultformat = "metafun" -function metapost.graphic(instance,mpsformat,str,preamble,askedfig) +function metapost.graphic(instance,mpsformat,str,initializations,preamble,askedfig) local mpx = metapost.format(instance,mpsformat or metapost.defaultformat) - metapost.graphic_base_pass(mpx,str,preamble,askedfig) + metapost.graphic_base_pass(mpx,str,initializations,preamble,askedfig) +end + +function metapost.getclippath(instance,mpsformat,data,initializations,preamble) + local mpx = metapost.format(instance,mpsformat or metapost.defaultformat) + if mpx and data then + starttiming(metapost) + starttiming(metapost.exectime) + local result = mpx:execute(format("%s;beginfig(1);%s;%s;endfig;",preamble or "",initializations or "",data)) + stoptiming(metapost.exectime) + if result.status > 0 then + logs.report("metafun", "%s: %s", result.status, result.error or result.term or result.log) + result = nil + else + result = metapost.filterclippath(result) + end + stoptiming(metapost) + return result + end end function metapost.filterclippath(result) @@ -26,16 +46,25 @@ function metapost.filterclippath(result) local figure = figures[1] local objects = figure:objects() if objects then + local lastclippath for o=1,#objects do local object = objects[o] if object.type == "start_clip" then - return join(metapost.flushnormalpath(object.path,{ }),"\n") + lastclippath = object.path end end + return lastclippath end end end - return "" +end + +function metapost.theclippath(...) + local result = metapost.getclippath(...) + if result then -- we could just print the table + result = join(metapost.flushnormalpath(result),"\n") + sprint(result) + end end statistics.register("metapost processing time", function() |