1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43\registerctxluafile{masymptote}{}
44
45\unprotect
46
47\unexpanded\def\asymptote
48 {\dodoubleempty\module_asymptote}
49
50\unexpanded\def\module_asymptote[#1][#2]
51 {\iffirstargument
52 \begingroup
53 \getdummyparameters[#2]
54 \edef\lasttypesetbuffer{\ctxlua{moduledata.asymptote.process("asymptote:#1","\dummyparameter\c!type")}}
55 \externalfigure
56 [\lasttypesetbuffer]
57 [\c!controls=\lasttypesetbuffer,#2]
58 \endgroup
59 \fi}
60
61\unexpanded\def\startasymptote[#1]
62 {\begingroup
63 \dostartbuffer[asymptote:#1][startasymptote][stopasymptote]}
64
65\unexpanded\def\stopasymptote
66 {\endgroup}
67
68\definefittingpage
69 [asymptotepage]
70 [\c!align=\v!normal]
71
72\protect
73
74\continueifinputfile{masymptote.mkiv}
75
76\starttext
77
78\startasymptote[demo1]
79settings.prc = true ;
80
81import graph3 ;
82import palette ;
83
84size(6cm,6cm) ;
85size3(5cm,0) ;
86
87currentprojection = orthographic(3,6,12) ;
88currentlight = light(8,10,2) ;
89
90real g(pair z) { return 1z.x2z.y2 ; }
91real f(pair z) { return 2z.x2 ; }
92
93real x(real t) { return t ; }
94real y(real t) { return 0 ; }
95real z(real t) { return 1t2 ; }
96real a(real t) { return 1 ; }
97real b(real t) { return t ; }
98real c(real t) { return t2 ; }
99
100path3 p=graph(x,y,z,2,2,operator ..) ;
101path3 o=graph(a,b,c,2,2,operator ..) ;
102
103surface r = surface(f, (0,1), (2,1), nx = 3, Spline) ;
104surface s = surface(g, (2,2), (2,2), nx = 5, Spline) ;
105
106path3 q = (2,2,7) (2,2,7) (2,2,7) (2,2,7) cycle ;
107
108draw(q) ;
109
110draw(p, bluethick(), Arrow3) ;
111draw(o, bluethick(), Arrow3) ;
112
113draw(s, lightgray opacity(0.8), nolight, meshpen = black thick()) ;
114draw(r, lightgray opacity(0.8), nolight, meshpen = black thick()) ;
115
116draw((1,0,0) (2,0,2), black, Arrow3) ;
117draw((1,0,0) (1,1,0), black, Arrow3) ;
118\stopasymptote
119
120\startasymptote[demo2]
121size(6cm,6cm) ;
122
123fill((1cm,2cm) (3cm,3cm) (4cm,0cm) cycle);
124\stopasymptote
125
126
127
128\startluaparameterset[demo-1]
129 toolbar = true,
130 tree = false,
131 view = 'ortho'
132\stopluaparameterset
133
134\asymptote[demo1][type=prc,width=5cm,height=5cm,frame=on,display=yes,controls=yes,preview=yes]
135\asymptote[demo2][type=pdf,width=8cm,frame=on]
136
137
138
139
140
141
142
143\stoptext
144 |