1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23\writestatus{loading}{MetaPost Library Graphics Templates}
24
25\registerctxluafile{metalua}{}
26
27\continueifinputfile{metalua.mkiv}
28
29\starttext
30
31
32
33\startbuffer[testa]
34 blua for i=1,100,5 do elua
35 draw fullcircle scaled (blua p(i) elua * cm) withcolor green withpen pencircle scaled 4 ;
36 blua end elua
37
38 blua for i=1,100,10 do elua
39 draw fullcircle scaled (blua p(i) elua * cm) withcolor red withpen pencircle scaled 2 ;
40 blua end elua
41\stopbuffer
42
43\startMPpage[offset=10pt]
44 input "mpstemplate://buffer?name=test-a" ;
45\stopMPpage
46
47
48
49\startbuffer[testb]
50 <?lua for i=1,100,5 do ?>
51 draw fullcircle scaled (<?lua p(i) ?> * cm) withcolor green withpen pencircle scaled 4 ;
52 <?lua end ?>
53
54 <?lua for i=1,100,10 do ?>
55 draw fullcircle scaled (<?lua p(i) ?> * cm) withcolor red withpen pencircle scaled 2 ;
56 <?lua end ?>
57\stopbuffer
58
59\startMPpage[offset=10pt]
60 input "mpstemplate://buffer?name=test-b" ;
61\stopMPpage
62
63\startMPpage[offset=10pt]
64 picture p[] ;
65 input "mpstemplate://buffer?name=test-a&method=metapost" ;
66 p[1] := currentpicture ; currentpicture := nullpicture ;
67 input "mpstemplate://buffer?name=test-b&method=xml" ;
68 p[2] := currentpicture ; currentpicture := nullpicture ;
69 draw p[1] ysized 3cm ;
70 draw p[2] ysized 4cm shifted (4cm,0) ;
71\stopMPpage
72
73
74
75\startMPpage[offset=10pt]
76 draw image (loadfile("mpstemplate://buffer?name=test-a&method=metapost")) ysized 3cm shifted (4cm,0cm) ;
77 draw image (loadfile("mpstemplate://buffer?name=test-b&method=xml")) ysized 3cm shifted (0cm,4cm) ;
78 draw loadimage ("mpstemplate://buffer?name=test-a&method=metapost") ysized 4cm shifted (4cm,4cm) ;
79 draw loadimage ("mpstemplate://buffer?name=test-b&method=xml") ysized 4cm shifted (0cm,0cm) ;
80\stopMPpage
81
82
83
84\startluacode
85 context.startMPpage { offset = "10pt" }
86 for i=1,100,5 do
87 context("draw fullcircle scaled (%s * cm) withcolor green withpen pencircle scaled 4 ;",i)
88 end
89 for i=1,100,10 do
90 context("draw fullcircle scaled (%s * cm) withcolor red withpen pencircle scaled 2 ;",i)
91 end
92 context.stopMPpage()
93\stopluacode
94
95\stoptext
96 |