some progress on graphic object access
[mplib] / src / texk / web2c / mpdir / tests / test.lua
1
2 -- There are two interfaces:
3 -- new * run
4 -- or
5 -- new * execute^1 * finish
6
7 if false then 
8   mpx = mp.new({ini_version = true, command_line = "plain \\dump"})
9   print (mpx:run());
10   mpx = nil;
11 end
12
13 function dorun (m, s) 
14   local v = m:execute(s)
15 --  print ('<<term:'..v.term..'>>')
16   print ('<<log:'..v.log..'>>')
17   if v.fig then
18      for _,gs in ipairs(v.fig) do
19 --       print(gs:postscript())
20      end
21   end
22 end
23
24 -- chunks have to have 'complete file' nesting state
25 local lines = {
26  "prologues:=3;",
27  "path p;",
28  "p = (0,0){right}..(20,100)..(50,60)..(75,50)...(25,25)..cycle;",
29  "pickup pencircle scaled 2;",
30  "beginfig(1); fill p withcolor (1,0,0); draw p dashed evenly; endfig;",
31  "beginfig(2); fill p withcolor (0,1,0); draw p dashed evenly; endfig;",
32  "beginfig(3); fill p withcolor (0,0,1); draw p dashed evenly; endfig;",
33  "beginfig(4); fill p withcolor (1,1,0); draw p dashed evenly; endfig;",
34  [[beginfig(5); fill p withcolor (1,0,1); draw p dashed evenly; endfig; 
35    beginfig(6); fill p withcolor (0,1,1); draw p dashed evenly; endfig;]],
36  "beginfig(7); label(\"stuff\", (0,0)); endfig;",
37 }
38
39 function finder (a,b,c)
40    print(a,b,c)
41    if a == "mpost.map" then
42      return "/opt/tex/texmf-local/fonts/map/pdftex/pdftex.map"
43    end
44    if a =="cmr10.tfm" then
45      return "/opt/tex/texmf/fonts/tfm/public/cm/cmr10.tfm"
46    end
47    return a
48 end
49
50 mpx = mp.new({mem_name = "plain.mem", 
51               command_line = "\\relax ", 
52               find_file = finder})
53
54 for _,l in ipairs(lines) do
55    dorun (mpx, l)
56 end
57
58 v = mpx:finish();
59