-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathAsymptote.asy
379 lines (360 loc) · 15.7 KB
/
Asymptote.asy
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
// 2.70 https://asymptote.sourceforge.io/
// https://github.com/vectorgraphics/asymptote
//! keywords ===========================================================
// asy-keywords.el, asy.vim
access and as atleast
break
continue controls curl cycle
do default
else explicit
for from
if import include
new newframe
operator
private public
quote
readable restricted return
static struct
tension this typedef
unravel
var
while
//! types ===========================================================
// https://asymptote.sourceforge.io/doc/Data-types.html#Data-types
void bool int real pair triple string
path path3 guide guide3 pen transform transform3 frame file
curlSpecifier tensionSpecifier
arrowbar arrowbar3 suffix
//! structs ===========================================================
// plain.asy
align arrowhead
bool3 bounds
coord coords2 coords3
filltype
Label Legend light
margin marker
object
picture position projection
scaling side slice
transformation
// three.asy
arrowhead3
control
flatguide3
interaction
margin3 material
patch
render
scene surface
Tension tube
//! constants ===========================================================
// plain_constants.asy
true false null
nullpath
currentpen nullpen invisible defaultpen
nullframe currentpicture currentprojection currentlight
undefined inches inch cm bp pt mm cm
identity zeroTransform
pi infinity
//! functions ===========================================================
// https://asymptote.sourceforge.io/doc/Drawing-commands.html#Drawing-commands
// draw
void draw(picture pic=currentpicture, Label L="", path g, align align=NoAlign, pen p=currentpen, arrowbar arrow=None, arrowbar bar=None, margin margin=NoMargin, Label legend="", marker marker=nomarker);
frame legend(picture pic=currentpicture, int perline=1, real xmargin=legendmargin, real ymargin=xmargin, real linelength=legendlinelength, real hskip=legendhskip, real vskip=legendvskip, real maxwidth=0, real maxheight=0, bool hstretch=false, bool vstretch=false, pen p=currentpen);
void dot(frame f, pair z, pen p=currentpen, filltype filltype=dotfilltype);
void dot(picture pic=currentpicture, pair z, pen p=currentpen, filltype filltype=dotfilltype);
void dot(picture pic=currentpicture, Label L, pair z, align align=NoAlign, string format=defaultformat, pen p=currentpen, filltype filltype=dotfilltype);
void dot(picture pic=currentpicture, Label[] L=new Label[], pair[] z, align align=NoAlign, string format=defaultformat, pen p=currentpen, filltype filltype=dotfilltype);
void dot(picture pic=currentpicture, path[] g, pen p=currentpen, filltype filltype=dotfilltype);
void dot(picture pic=currentpicture, Label L, pen p=currentpen, filltype filltype=dotfilltype);
void dot(picture pic=currentpicture, Label[] L=new Label[], explicit path g, align align=RightSide, string format=defaultformat, pen p=currentpen, filltype filltype=dotfilltype);
void draw(pair origin, picture pic=currentpicture, Label L="", path g, align align=NoAlign, pen p=currentpen, arrowbar arrow=None, arrowbar bar=None, margin margin=NoMargin, Label legend="", marker marker=nomarker);
// fill
void filldraw(picture pic=currentpicture, path g, pen fillpen=currentpen, pen drawpen=currentpen);
void fill(pair origin, picture pic=currentpicture, path g, pen p=currentpen);
void filloutside(picture pic=currentpicture, path g, pen p=currentpen);
void latticeshade(picture pic=currentpicture, path g, bool stroke=false, pen fillrule=currentpen, pen[][] p)
void axialshade(picture pic=currentpicture, path g, bool stroke=false, pen pena, pair a, bool extenda=true, pen penb, pair b, bool extendb=true);
void radialshade(picture pic=currentpicture, path g, bool stroke=false, pen pena, pair a, real ra, bool extenda=true, pen penb, pair b, real rb, bool extendb=true);
void gouraudshade(picture pic=currentpicture, path g, bool stroke=false, pen fillrule=currentpen, pen[] p, pair[] z, int[] edges);
void gouraudshade(picture pic=currentpicture, path g, bool stroke=false, pen fillrule=currentpen, pen[] p, int[] edges);
void tensorshade(picture pic=currentpicture, path[] g, bool stroke=false, pen fillrule=currentpen, pen[][] p, path[] b=g, pair[][] z=new pair[][]);
void tensorshade(picture pic=currentpicture, path g, bool stroke=false, pen fillrule=currentpen, pen[] p, path b=g, pair[] z=new pair[]);
void draw(picture pic=currentpicture, pen fillrule=currentpen, path[] g, pen[] p);
void functionshade(picture pic=currentpicture, path[] g, bool stroke=false, pen fillrule=currentpen, string shader);
void unfill(picture pic=currentpicture, path g);
// clip
void clip(picture pic=currentpicture, path g, stroke=false, pen fillrule=currentpen);
// https://asymptote.sourceforge.io/doc/Data-types.html#Data-types
// pair
pair conj(pair z)
real length(pair z)
real angle(pair z, bool warn=true)
real degrees(pair z, bool warn=true)
pair unit(pair z)
pair expi(real angle)
pair expi(real angle)
real xpart(pair z)
real ypart(pair z)
pair realmult(pair z, pair w)
real dot(explicit pair z, explicit pair w)
real cross(explicit pair z, explicit pair w)
real orient(pair a, pair b, pair c);
real incircle(pair a, pair b, pair c, pair d);
pair minbound(pair z, pair w)
pair maxbound(pair z, pair w)
// triple
real length(triple v)
real polar(triple v, bool warn=true)
real azimuth(triple v, bool warn=true)
real colatitude(triple v, bool warn=true)
real latitude(triple v, bool warn=true)
real longitude(triple v, bool warn=true)
triple unit(triple v)
triple expi(real polar, real azimuth)
triple dir(real colatitude, real longitude)
real xpart(triple v)
real ypart(triple v)
real zpart(triple v)
real dot(triple u, triple v)
triple cross(triple u, triple v)
triple minbound(triple u, triple v)
triple maxbound(triple u, triple v)
// string
int length(string s)
int find(string s, string t, int pos=0)
int rfind(string s, string t, int pos=-1)
string insert(string s, int pos, string t)
string erase(string s, int pos, int n)
string substr(string s, int pos, int n=-1)
string reverse(string s)
string replace(string s, string before, string after)
string replace(string s, string[][] table)
string[] split(string s, string delimiter="")
string[] array(string s)
string format(string s, int n, string locale="")
string format(string s=defaultformat, bool forcemath=false, string s=defaultseparator, real x, string locale="")
int hex(string s);
int ascii(string s);
string string(real x, int digits=realDigits)
string locale(string s="")
string time(string format="%a %b %d %T %Z %Y")
int seconds(string t="", string format="")
string time(int seconds, string format="%a %b %d %T %Z %Y")
int system(string s)
int system(string[] s)
void asy(string format, bool overwrite=false ... string[] s)
void abort(string s="")
void assert(bool b, string s="")
void exit()
void sleep(int seconds)
void usleep(int microseconds)
void beep()
// https://asymptote.sourceforge.io/doc/Paths-and-guides.html#Paths-and-guides
int length(path p);
int size(path p);
bool cyclic(path p);
bool straight(path p, int i);
bool piecewisestraight(path p)
pair point(path p, int t);
pair point(path p, real t);
pair dir(path p, int t, int sign=0, bool normalize=true);
pair dir(path p, real t, bool normalize=true);
pair dir(path p)
pair dir(path p, path q)
pair accel(path p, int t, int sign=0);
pair accel(path p, real t);
real radius(path p, real t);
pair precontrol(path p, int t);
pair precontrol(path p, real t);
pair postcontrol(path p, int t);
pair postcontrol(path p, real t);
real arclength(path p);
real arctime(path p, real L);
pair arcpoint(path p, real L);
real dirtime(path p, pair z);
real reltime(path p, real l);
pair relpoint(path p, real l);
pair midpoint(path p);
path reverse(path p);
path subpath(path p, int a, int b);
path subpath(path p, real a, real b);
real[] intersect(path p, path q, real fuzz=-1);
real[][] intersections(path p, path q, real fuzz=-1);
real[] intersections(path p, explicit pair a, explicit pair b, real fuzz=-1);
real[] times(path p, real x)
real[] times(path p, explicit pair z)
real[] mintimes(path p)
real[] maxtimes(path p)
pair intersectionpoint(path p, path q, real fuzz=-1);
pair[] intersectionpoints(path p, path q, real fuzz=-1);
pair extension(pair P, pair Q, pair p, pair q);
slice cut(path p, path knife, int n);
slice firstcut(path p, path knife);
slice lastcut(path p, path knife);
path buildcycle(... path[] p);
pair min(path p);
pair max(path p);
int windingnumber(path p, pair z);
bool interior(int windingnumber, pen fillrule)
bool inside(path p, pair z, pen fillrule=currentpen);
int inside(path p, path q, pen fillrule=currentpen);
pair inside(path p, pen fillrule=currentpen);
path[] strokepath(path g, pen p=currentpen);
// guide
int size(guide g);
int length(guide g);
bool cyclic(path p);
pair point(guide g, int t);
guide reverse(guide g);
pair[] dirSpecifier(guide g, int i);
pair[] controlSpecifier(guide g, int i);
tensionSpecifier tensionSpecifier(guide g, int i);
real[] curlSpecifier(guide g);
// https://asymptote.sourceforge.io/doc/Pens.html#Pens
pen gray(real g);
pen rgb(real r, real g, real b);
pen cmyk(real c, real m, real y, real k);
defaultpen(pen)
colorspace(pen p)
colorless(pen=currentpen)
pen rgb(string s);
string hex(pen p);
pen linetype(real[] a, real offset=0, bool scale=true, bool adjust=true)
pen linewidth(real)
real linewidth(pen p=currentpen)
int linecap(pen p=currentpen)
int linejoin(pen p=currentpen)
real miterlimit(pen p=currentpen)
int fillrule(pen p=currentpen)
int basealign(pen p=currentpen)
pen fontsize(real size, real lineskip=1.2*size)
real fontsize(pen p=currentpen)
real lineskip(pen p=currentpen)
pen font(string encoding, string family, string series, string shape)
string font(pen p=currentpen)
pen opacity(real opacity=1, string blend="Compatible")
picture hatch(real H=5mm, pair dir=NE, pen p=currentpen)
picture crosshatch(real H=5mm, pen p=currentpen)
pen makepen(path)
path nib(pen)
// https://asymptote.sourceforge.io/doc/Transforms.html#Transforms
transform shift(pair z);
transform shift(real x, real y);
transform xscale(real x);
transform yscale(real y);
transform scale(real s);
transform scale(real x, real y);
transform slant(real s);
transform rotate(real angle, pair z=(0,0));
transform reflect(pair a, pair b);
// https://asymptote.sourceforge.io/doc/Frames-and-pictures.html#Frames-and-pictures
// frame
void add(frame dest, frame src);
void prepend(frame dest, frame src);
frame align(frame f, pair align);
path box(frame f, Label L="", real xmargin=0, real ymargin=xmargin, pen p=currentpen, filltype filltype=NoFill, bool above=true);
path roundbox(frame f, Label L="", real xmargin=0, real ymargin=xmargin, pen p=currentpen, filltype filltype=NoFill, bool above=true);
path ellipse(frame f, Label L="", real xmargin=0, real ymargin=xmargin, pen p=currentpen, filltype filltype=NoFill, bool above=true);
// picture
void size(picture pic=currentpicture, real x, real y=x, bool keepAspect=Aspect);
void unitsize(picture pic=currentpicture, real x, real y=x);
transform fixedscaling(picture pic=currentpicture, pair min, pair max, pen p=nullpen, bool warn=false);
void shipout(string prefix=defaultfilename, picture pic=currentpicture, orientation orientation=orientation, string format="", bool wait=false, bool view=true, string options="", string script="", light light=currentlight, projection P=currentprojection)
fit(real xsize=pic.xsize, real ysize=pic.ysize, bool keepAspect=pic.keepAspect);
scale(real xsize=this.xsize, real ysize=this.ysize, bool keepAspect=this.keepAspect);
frame bbox(picture pic=currentpicture, real xmargin=0, filltype filltype=NoFill);
filldraw(real xmargin=0, real ymargin=xmargin, pen fillpen=nullpen, pen drawpen=nullpen)
fill(real xmargin=0, real ymargin=xmargin, pen p=nullpen)
draw(real xmargin=0, real ymargin=xmargin, pen p=nullpen)
unfill(real xmargin=0, real ymargin=xmargin)
radialshade(pen penc, pen penr)
radialshadedraw(real xmargin=0, real ymargin=xmargin, pen penc, pen penr, pen drawpen=nullpen)
frame pad(picture pic=currentpicture, real xsize=pic.xsize, real ysize=pic.ysize, filltype filltype=NoFill);
pair min(picture pic, user=false);
pair max(picture pic, user=false);
pair size(picture pic, user=false);
pair point(picture pic=currentpicture, pair dir, bool user=true);
pair truepoint(picture pic=currentpicture, pair dir, bool user=true);
void add(picture src, bool group=true, filltype filltype=NoFill, bool above=true);
void add(picture dest, picture src, bool group=true, filltype filltype=NoFill, bool above=true);
void add(picture src, pair position, bool group=true, filltype filltype=NoFill, bool above=true);
void add(picture dest, picture src, pair position, bool group=true, filltype filltype=NoFill, bool above=true);
void add(picture dest=currentpicture, frame src, pair position=0, bool group=true, filltype filltype=NoFill, bool above=true);
void add(picture dest=currentpicture, frame src, pair position, pair align, bool group=true, filltype filltype=NoFill, bool above=true);
void attach(picture dest=currentpicture, frame src, pair position=0, bool group=true, filltype filltype=NoFill, bool above=true);
void attach(picture dest=currentpicture, frame src, pair position, pair align, bool group=true, filltype filltype=NoFill, bool above=true);
void erase(picture pic=currentpicture);
void postscript(picture pic=currentpicture, string s);
void postscript(picture pic=currentpicture, string s, pair min, pair max)
void tex(picture pic=currentpicture, string s);
void tex(picture pic=currentpicture, string s, pair min, pair max)
void texpreamble(string s);
void texreset();
void usepackage(string s, string options="");
// https://asymptote.sourceforge.io/doc/Files.html#Files
input(string name="", bool check=true, string comment="#", string mode="");
file output(string name="", bool update=false, string comment="#", string mode="");
write(string s="", T x, suffix suffix=endl ... T[]);
write(file file, string s="", T x, suffix suffix=none ... T[]);
write(file file=stdout, string s="", explicit T[] x ... T[][]);
write(file file=stdout, T[][]);
write(file file=stdout, T[][][]);
write(suffix suffix=endl);
write(file file, suffix suffix=none);
eof(file)
eol(file)
error(file)
flush(file)
clear(file)
close(file)
int precision(file file=stdout, int digits=0)
int tell(file)
seek(file file, int pos)
seekeof(file)
string getstring(string name="", string default="", string prompt="", bool store=true);
int getint(string name="", int default=0, string prompt="", bool store=true);
real getreal(string name="", real default=0, string prompt="", bool store=true);
pair getpair(string name="", pair default=0, string prompt="", bool store=true);
triple gettriple(string name="", triple default=(0,0,0), string prompt="", bool store=true);
string readline(string prompt="", string name="", bool tabcompletion=false);
void saveline(string name, string value, bool store=true);
int delete(string s)
int rename(string from, string to)
int convert(string args="", string file="", string format="");
int animate(string args="", string file="", string format="");
// https://asymptote.sourceforge.io/doc/Arrays.html#Arrays
T push(T x),
void append(T[] a),
T pop(),
void insert(int i ... T[] x),
void delete(int i, int j=i),
void delete(), and
bool initialized(int n).
T[] array(int n, T value, int depth=intMax)
int[] sequence(int n)
T[] map(T f(T), T[] a)
int[] reverse(int n)
int[] complement(int[] a, int n)
real[] uniform(real a, real b, int n)
int find(bool[] a, int n=1)
int[] findall(bool[] a)
int search(T[] a, T key)
T[] copy(T[] a)
T[] concat(... T[][] a)
bool alias(T[] a, T[] b)
T[] sort(T[] a)
T[][] transpose(T[][] a)
T sum(T[] a)
T min(T[] a)
T max(T[] a)
pair[] pairs(real[] x, real[] y);
pair[] fft(pair[] a, int sign=1)
real dot(real[] a, real[] b)
real[] tridiagonal(real[] a, real[] b, real[] c, real[] f);
real[] solve(real[][] a, real[] b, bool warn=true)
real[][] identity(int n);
real[][] diagonal(... real[] a)
real[][] inverse(real[][] a)
real[] quadraticroots(real a, real b, real c);
real[] cubicroots(real a, real b, real c, real d);