2 -- There are two interfaces:
5 -- new * execute^1 * finish
8 mpx = mplib.new({ini_version = true})
9 vv = mpx:execute("plain ");
10 v = mpx:execute("dump;");
12 print (tostring(vv.term) .. ' ' .. tostring(v.term) .. ' ' .. tostring(vvv.term))
13 print (tostring(vv.log) .. ' ' .. tostring(v.log) .. ' ' .. tostring(vvv.log))
14 print (tostring(vv.error) .. ' ' .. tostring(v.error) .. ' ' .. tostring(vvv.error))
18 dofile("/opt/tex/texmf-local/tex/context/base/l-table.lua");
21 local v = m:execute(s)
22 -- print ('<<term:'..v.term..'>>')
24 print ('<<log:'..v.log..'>>')
26 if true and v.fig then
27 for _,gs in ipairs(v.fig) do
28 print(gs:postscript())
29 local b = gs:objects()
30 for _,vv in ipairs(b) do
33 if vv.type == "text" then
34 print(vv.text, vv.font, vv.dsize, table.serialize(vv.transform))
41 -- chunks have to have 'complete file' nesting state
46 "p = (0,0){right}..(20,100)..(50,60)..(75,50)...(25,25)..cycle;",
47 "q = (0,0){right}..(20,100)..(50,60)..(75,50)...(25,25);",
48 "pickup pencircle scaled 2;",
49 "beginfig(1); fill p withcolor (1,0,0); draw p dashed evenly; endfig;",
50 -- [[for i=1 upto 1000 : beginfig(1); for k:=1 upto 10 : draw fullcircle scaled (uniformdeviate(10mm)) ;endfor; endfig ; endfor ;]],
51 [[beginfig(2); fill p withcolor (1,0,1); endfig;
\r
52 beginfig(3); draw q withcolor (0,1,1); endfig;]],
53 "beginfig(4); label(\"stuff\", (0,0)); endfig;",
54 "beginfig(5); draw fullcircle scaled 100 withpen pencircle xscaled 20 yscaled 10 rotated 30 ; endfig;",
57 function finder (a,b,c)
59 if a == "mpost.map" then
60 return "/opt/tex/texmf-local/fonts/map/pdftex/pdftex.map"
62 if a =="cmr10.tfm" then
63 return "/opt/tex/texmf/fonts/tfm/public/cm/cmr10.tfm"
68 mpx = mplib.new({mem_name = "plain.mem",
69 command_line = "\\relax ",
72 for _,l in ipairs(lines) do