You are on page 1of 100

Asymptote:

1.79

symptote

Asymptote 1.79
http://asymptote.sourceforge.net
20049 Andy Hammerlindl, John Bowman, and Tom Prince.
GNU Lesser General Public LicenseGNU
LICENSE /
leoliu.pku@gmail.com 2009 7 6
ii

Asymptote 1.79
LATEX

7
4.1 draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.2 ll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.3 clip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.4 label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

17
5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2 pathguide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.5 framepicture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.9.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.9.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.9.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.11.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.11.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.11.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.11.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5.12.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

iii
iv

5.13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.15 static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

84

Asymptote 1 http://www.artofproblemsolving.com/
Wiki/index.php/Asymptote:_Basics
Asymptote (0, 0) (100, 100)

asy
draw((0,0)--(100,100));

PostScript big point2 , 1 bp = 1/72 inch--


Asymptote (0,0) (1000,100) pair
quit
GNU readline
Tab tab
9 Interactive Mode3
Asymptote

draw((0,0)--(100,100));

test.asy MSDOS UNIX


1
Asymptote Philippe Ivaldi Asymptote
Asymptote Asymptote
lapackapi@ctex.orgAsymptote cvgmt@ctex.org
goodluck@ctex.org Asymptote FAQ CTEX

2
big point TEX TEX 1/72 inch point, pt TEX
1 pt = 1/72.27 inch

3

1
2

asy -V test

Windows 4 asy Asymptote asy

-V PostScript PostScript
test.eps -o

draw((0,0)--(100,0)--(100,100)--(0,100)--cycle);

PostScript 101 bp 101 bp

size(101,101);
draw((0,0)--(1,0)--(1,1)--(0,1)--cycle);

(0,0)--(1,0)--(1,1)--(0,1)--cycle unitsquare
box((0,0),(1,1))
pt1 pt = 1/72.27 inchcmmm inches5 size
0 45 5.5 size

size(0,3cm);
draw(unitsquare);

1cm

unitsize(1cm);
draw(unitsquare);
4
MSDOS Windows
5
inch inches
3

x y

unitsize(1cm,2cm);
draw(unitsquare);

Asymptote LATEX

size(0,3cm);
draw(unitsquare);
label("$A$",(0,0),SW);
label("$B$",(1,0),SE);
label("$C$",(1,1),NE);
label("$D$",(0,1),NW);

D C

A B

Asymptote E=(1,0)N=(0,1)NE=unit(N+E) ENE=unit(E+NE)


Asymptote plain pair) updownright left E
Eplain.E
1/4

size(100,0);
draw((1,0){up}..{left}(0,1));

-- ..
cycle
0.06%

path unitcircle=E..N..W..S..cycle;
4

{dir} dir

c0 z0 c1 z1 Bzier

(1 t)3 z0 + 3t(1 t)2 c0 + 3t2 (1 t)c1 + t3 z1 , 06t61

6
z0 z1 c0 c1 m5
(z0 , c0 , c1 , z1 ) Bzier t = 1/2

c0 m1 c1

m3 m5 m4

m0
m2

z0 z1

m0 , m1 m2 m3 m4 m5
(z0 , m0 , m3 , m5 ) (m5 , m4 , m2 , z1 )
[0, 1] t
t = 1/2
Bzier

draw((0,0)..controls (0,100) and (100,100)..(100,0));

.. Asymptote Donald Knuth The


METAFONTbook 14

1
0.75 John D. Hobby, Discrete and Computational Geometry 1, 1986
6
Bzier
METAPOST METAPOST: A Users Manual 4 Curves METAPOST ConTEXt
METAFUN 1
5

draw((100,0)..tension 2 ..(100,100)..(0,100));
draw((100,0)..tension 2 and 1 ..(100,100)..(0,100));
draw((100,0)..tension atleast 1 ..(100,100)..(0,100));

0 1

draw((100,0){curl 0}..(100,100)..{curl 0}(0,100));

METAPOST ...
Asymptote .. tension atleast 1 .. :: ...
Asymptote 66 5.11.3

draw((0,0){up}..(100,25){right}..(200,0){down});

draw((0,0){up}::(100,25){right}::(200,0){down});

--- ..tension atleast infinity.. 7 &

Asymptote PostScript subpath^^



Asymptote path[] PostScript

size(0,100);
path unitcircle=E..N..W..S..cycle;
path g=scale(2)*unitcircle;
filldraw(unitcircle^^g,evenodd+yellow,black);

7

6

PostScript evenodd8
zerowinding

filldraw(unitcircle^^reverse(g),yellow,black);

^^ three.asy box(triple, triple) unitbox

import three;
dotgranularity=0; // Render dots as spheres.

currentprojection=orthographic(5,4,2,center=true);

size(5cm);
size3(3cm,5cm,8cm);

draw(unitbox);

dot(unitbox,red);

label("$O$",(0,0,0),NW);
label("(1,0,0)",(1,0,0),S);
label("(0,1,0)",(0,1,0),E);
label("(0,0,1)",(0,0,1),Z);

7.25 graph 9 Asymptote http://asymptote.sourceforge.


net Philippe Ivaldi
http://piprim.tuxfamily.org/asymptote/

8

9

Asymptote PostScript drawfill clip


label
EPS PostScript
picture shipout 45 5.5
shipout
TEX 45 5.5 tex PostScript
layer PostScript/LATEX

void layer(picture pic=currentpicture);

layer layer
TEX PostScript
currentpicture

4.1 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);

pic p g L align
arrow bar margin legend marker
arrow bar 1 legend

bar NoneBeginBarEndBar Bar Bars


None PostScript
barsize(pen)
arrow NoneBlank2 BeginArrowMidArrowEndArrow
1
draw(g, BeginBar, EndArrow) draw(g, EndArrow, BeginBar)
2

7
8

Arrow Arrows None Blank


arrowhead DefaultSimpleHead HookHeadTeXHead
sizePostScript angle
filltypeFillDraw FillNoFillUnFillDraw MidArrow Arrows
position arctime p
arrowsize(p) size angle 3 BeginArcArrow
EndArcArrow ArcArrow MidArcArrow ArcArrows
labelmargin(p) margin
NoMarginBeginMarginEndMargin Margin Margins
Margin(real begin, real end) labelmargin(p)
BeginPenMargin EndPenMargin
PenMarginPenMarginsPenMargin(real begin, real end)
DotMargin PenMargin(-0.5*dotfactor,0.5*dotfactor)
dotfactor*linewidth(p)
BeginDotMarginEndDotMargin DotMargins TrueMargin(real begin, real end)
PostScript
Pythagoras.asysqrtx01.asy triads.asy 4
pic

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);

xmargin ymargin x y perline 10


linelength hskip vskip
maxwidth maxheight 0 hstretch vstretch
p add attach
dest 45 5.5 add
plain dot
3
TeXHead
4
Pythagoras.asy

c
a

a b

4.2 FILL 9

dotfactor 6
45 5.5

void dot(picture pic=currentpicture, pair z, pen p=currentpen,


filltype filltype=Fill);
void dot(picture pic=currentpicture, Label L, pair z, align align=NoAlign,
string format=defaultformat, pen p=currentpen, filltype filltype=Fill);
void dot(picture pic=currentpicture, Label[] L=new Label[], pair[] z,
align align=NoAlign, string format=defaultformat, pen p=currentpen,
filltype filltype=Fill)
void dot(picture pic=currentpicture, Label L, pen p=currentpen,
filltype filltype=Fill);

Label Label format


defaultformat "$%.4g$" z

void dot(picture pic=currentpicture, Label[] L=new Label[],


path g, align align=RightSide, string format=defaultformat,
pen p=currentpen, filltype filltype=Fill);

7.25 graph 7.8 markers 5


origin PostScript

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);

4.2 ll

void fill(picture pic=currentpicture, path g, pen p=currentpen);

p pic g
filldraw

void filldraw(picture pic=currentpicture, path g, pen fillpen=currentpen,


pen drawpen=currentpen);

fill origin PostScript

void fill(pair origin, picture pic=currentpicture, path g, pen p=currentpen);


5

10

picture opic;
fill(opic,g,p);
add(pic,opic,origin);

void filloutside(picture pic=currentpicture, path g, pen p=currentpen);

g pic
p fillrule

void latticeshade(picture pic=currentpicture, path g, bool stroke=false,


pen fillrule=currentpen, pen[][] p);

stroke=true draw(pic,g,fillrule+zerowinding) 6
g p rgb(pen)
cmyk(pen) latticeshading.asy 7
a--b pena penb 8

void axialshade(picture pic=currentpicture, path g, bool stroke=false,


pen pena, pair a,
pen penb, pair b);

a ra pena b rb penb

void radialshade(picture pic=currentpicture, path g, bool stroke=false,


6

7
latticeshade RGB CMYK p
latticeshading.asy

size(200);

pen[][] p={{white,grey,black},
{red,green,blue},
{cyan,magenta,yellow}};

latticeshade(unitsquare,p);

unitsize(1cm);
path g = ellipse((0,0), 4, 1);
axialshade(g, green, (-4,0), yellow, (4,0));
axialshade(shift(0,-2.5)*g, stroke=true,
green+linewidth(2mm), (-4,0), yellow, (4,0));

4.2 FILL 11

pen pena, pair a, real ra,


pen penb, pair b, real rb);

shade.asyring.asy shadestroke.asy 9
z edges fillrule p
Gouraud

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);

z g p Gouraud
Gouraud.asy solids.asy 10 Gouraud
http://partners.adobe.com/public/developer/en/ps/sdk/TN5600.SmoothShading.pdf
b 4 n n 4 p n 4
fillrule

void tensorshade(picture pic=currentpicture, path g, bool stroke=false,


pen fillrule=currentpen, pen[][] p, path[] b=g,
pair[][] z=new pair[][]);

z Coons p
n = 1

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, path[] g, pen[] p);


9
shadestroke.asy

size(100);

radialshade(W..N..E--(0,0),stroke=true,
red+linewidth(30),(0,0),0.25,yellow,(0,0),1);

10
p Gouraud.asy
(0,1)

2
1

(1,0) (1,0)
0 (0,0)

12

Coons tensor.asy Coons.asyBezierSurface.asy rainbow.asy 11


pdfLATEX, ConTEXt pdfTEX TEX

void functionshade(picture pic=currentpicture, path[] g, bool stroke=false,


pen fillrule=currentpen, string shader);

shader PostScript fillrule pic g


PostScript 2 [0, 1] colors(fillrule).length
functionshading.asy
evenodd ^^

void unfill(picture pic=currentpicture, path g);

4.3 clip

void clip(picture pic=currentpicture, path g, stroke=false,


pen fillrule=currentpen);

fillrule 34 5.3 pic g


stroke=true draw(pic,g,fillrule+zerowinding)
g 6 LATEX usage 12

4.4 label

void label(picture pic=currentpicture, Label L, pair position,


align align=NoAlign, pen p=nullpen, filltype filltype=NoFill)

p pic L align NoAlign position


align position PostScript align*labelmargin(p)
11
Coons

size(200);

pen[] p={red,green,blue,magenta};
path g=(0,0){dir(45)}..(1,0)..(1,1)..(0,1)..cycle;
tensorshade(g,p);
dot(g);

12

picture pic;
path C1 = circle((0,0), 1cm), C2 = circle((1cm,0), 1cm);
fill(C1, paleblue); draw(pic, C2, linewidth(2mm));
fill(pic, C1, heavyblue); clip(pic, C2);
add(pic);

4.4 LABEL 13

Align position p nullpen


currentpen L

Label Label(string s="", pair position, align align=NoAlign,


pen p=nullpen, embed embed=Rotate, filltype filltype=NoFill);
Label Label(string s="", align align=NoAlign,
pen p=nullpen, embed embed=Rotate, filltype filltype=NoFill);
Label Label(Label L, pair position, align align=NoAlign,
pen p=nullpen, embed embed=L.embed, filltype filltype=NoFill);
Label Label(Label L, align align=NoAlign,
pen p=nullpen, embed embed=L.embed, filltype filltype=NoFill);

44 5.4
rotate(45)*xscale(2)*L x L 45
PostScript shift(10,0)*Lembed

Shift

Rotate

Rotate(pair z)
z

Slant

Scale

void label(picture pic=currentpicture, Label L, path g, align align=NoAlign,


pen p=nullpen, filltype filltype=NoFill);

0 length(g) arctime 25
5.2 arctime position Relative(real)
13
13
Label position

Label Label(string s, string size="", explicit position position,


align align=NoAlign, pen p=nullpen, embed embed=Rotate,
filltype filltype=NoFill);
14

position BeginPoint=Relative(0);
position MidPoint=Relative(0.5);
position EndPoint=Relative(1);

align pair
Relative(pair) 14 LeftSideCenter RightSide
Relative(W)Relative((0,0)) Relative(E) LeftSideCenter RightSide
15
dir b arrowlength

void arrow(picture pic=currentpicture, Label L="", pair b, pair dir,


real length=arrowlength, align align=NoAlign,
pen p=currentpen, arrowbar arrow=Arrow, margin margin=EndMargin);

align
dir
string graphic(string name, string options="") PostScript
Encapsulated PostScriptEPSname options
bb=llx lly urx urywidth=value
height=valueangle=valuescale=factor clip=bool
draft=boollayer()

label(graphic("file.eps","width=1cm"),(0,0),NE);
layer();

Label Label(Label L, explicit position position, align align=NoAlign,


pen p=nullpen, embed embed=L.embed, filltype filltype=NoFill);

position Relative(value)
14
Relative(N) Label position align

Relative(0.5)=MidPoint
1

0.5
LeftSide N Relative(0.8)
W E
RightSide S
)
(S
ve
ti
la
Re

Label
0 position align 2

15
13 Label plain pair

Label Label(pair position, align align=NoAlign, pen p=nullpen,


embed embed=Rotate, filltype filltype=NoFill);

4.4 LABEL 15

string baseline(string s, string template="\strut")


Pythagoras.asy 16

overwrite 34 5.3

plain_Label.asy object

frame pack(pair align=2S ... object inset[]);

object draw(picture pic=currentpicture, Label L, envelope e,


real xmargin=0, real ymargin=xmargin, pen p=currentpen,
filltype filltype=NoFill, bool above=true);
object draw(picture pic=currentpicture, Label L, envelope e, pair position,
real xmargin=0, real ymargin=xmargin, pen p=currentpen,
filltype filltype=NoFill, bool above=true);

envelope plain_boxes.asy 25 5.2 box roundbox


ellipse

path[] texpath(Label L) TEX L

string minipage(string s, width=100pt) s width


minipageclip graphic CD

16
Pythagoras.asy 4
16

Asymptote
The Vector Graphics Language
Andy Hammerlindl, John Bowman, and Tom Prince
http://asymptote.sourceforge.net

symptote

size(11.7cm,11.7cm);
asy(nativeformat(),"logo");
fill(unitcircle^^(scale(2/11.7)*unitcircle),
evenodd+rgb(124/255,205/255,124/255));
label(scale(1.1)*minipage(
"\centering\scriptsize\textbf{\LARGE{\ttAsymptote}\\
\smallskip
\smallTheVectorGraphicsLanguage}\\
\smallskip
\textsc{AndyHammerlindl,JohnBowman,andTomPrince}
http://asymptote.sourceforge.net\\
",8cm),(0,0.6));
label(graphic("logo."+nativeformat(),"height=7cm"),(0,-0.22));
clip(unitcircle^^(scale(2/11.7)*unitcircle),evenodd);

Asymptote C, C++ Java


1

//

// x real
real x;

// real x 1
x=1.0;

// x 1
if(x == 1.0) {
write("x1.0");
} else {
write("x1.0");
}

// 10
for(int i=0; i < 10; ++i) {
write(i);
}

C/C++ Asymptote while, do, break continue Java

//
int[] array={1,1,2,3,5};
for(int k : array) {
write(k);
1
C, C++ Java do

17
18

5.1
Asymptote

void void

bool true false

bool b = true;

b true

bool b;

false

bool3 true, default false bool3 bool


bool3 default

int 0 intMin
intMax

real 0.0
realEpsilon realDigits realMin
realMax

pair (x, y) z z.x z.y x y


(0.0,0.0)

pair z=(3,4);
z=(z.x,-z.y);
z=z.x-I*z.y;
z=conj(z);

I (0,1)

pair conf(pair z)
z

real length(pair z)
z |z|
5.1 19

pair z=(3,4);
length(z);

5abs(pair) length(pair)

real angle(pair z, bool warn=true)


z [, ] warn false z = (0,0)
0

real degrees(pair z, bool warn=true)


z [0, 360) warn false z = (0,0)
0

pair unit(pair z)
z

pair expi(real angle)


angle

pair dir(real degrees)


degrees

real xpart(pair z)
z.x

real ypart(pair z)
z.y

pair realmult(pair z, pair w)


(z.x*w.x,z.y*w.y)

real dot(pair z, pair w)


z.x*w.x+z.y*w.y

pair minbound(pair z, pair w)


(min(z.x,w.x),min(z.y,w.y))

pair maxbound(pair z, pair w)


(max(z.x,w.x),max(z.y,w.y))
20

triple (x,y,z) v v.x, v.y


v.z (0.0,0.0,0.0)

real length(triple v)
v |v|abs(triple) length(triple)

real polar(triple v, bool warn=true)


v z warn false v = O 2 0

real azimuth(triple v, bool warn=true)


v x warn false v.x = v.y = 0
0

real colatitude(triple v, bool warn=true)


v z warn false v = O 0

real latitude(triple v, bool warn=true)


v xy warn false v = O 0

real longitude(triple v, bool warn=true)


v x warn false v.x = v.y = 0
0

triple unit(triple v)
v

triple expi(real polar, real azimuth)


(polar,azimuth)

triple dir(real colatitude, real longitude)


(colatitude,longitude)

real xpart(triple v)
v.x
2
v 0 O three (0,0,0)
5.1 21

real ypart(triple v)
v.y

real zpart(triple v)
v.z

triple realmult(triple u, triple v)


3 (u.x*v.x, u.y*v.y, u.z*v.z)

real dot(triple u, triple v)


u.x*v.x+u.y*v.y+u.z*v.z

triple cross(triple u, triple v)


(u.y*v.z-u.z*v.y,u.z*v.x-u.x*v.z,u.x*v.y-v.x*u.y)

triple minbound(triple u, triple v)


(min(u.x,v.x),min(u.y,v.y),min(u.z,v.z))

triple maxbound(triple u, triple v)


(max(u.x,v.x),max(u.y,v.y),max(u.z,v.z))

string STL string


" TEX bable
7.21 babel4

\" "
\\ \\

' ANSI C

\' '
\" "
\? ?
\\
\a
\b
\f
3

4

22

\n
\r
\t
\v
\0\377
\x0xFF 5

"" + 0

int length(string s)
s

int find(string s, string t, int pos=0)


t s pos t s
-1

int rfind(string s, string t, int pos=-1)


t s pos pos = -1 s
t s -1

string insert(string s, int pos, string t)


t s pos

string erase(string s, int pos, int n)


s pos n n = -1 s

string substr(string s, int pos, int n=-1)


pos n n = -1 s

string reverse(string s)
s

string replace(string s, string before, string after)


s before after
5
C Asymptote C
0177 0x2F
5.1 23

string replace(string s, string[][] table)


s table {before,after} before
after

string[] split(string s, string delimiter)


s delimiter

string format(string s, int n)


locale n C 6

string format(string s=defaultformat, real x, string locale="")


locale C fprintf
C x
#TEX
7

int hex(string s)
s

string string(real x, int digits=realDigits)


digits C locale x

string locale(string s="")


string time(string format="%a%b%d%T%Z%Y")


ANSI C strftime format 8

time();
time("%a%b%d%H:%M:%S%Z%Y");
6
format("%04d", 3) "0003" Asymptote hlll
%d %i %o%x %X%u
# # 0 0x0X
%*d
format("%"+string(4)+"d", 3)
7
Asymptote Windows
L %f %e %g
# format(string, int)
1.77 $
format("%010.5f", pi) 0003.14159 format("%+.3g", 0.00001234) +1.23e-05
format("$%+.3g$", 0.00001234) $+1.23\!\times\!10^{-5}$
8
K&R C99
24

Unix date

int seconds(string t="", string format="")


UTC 1970 1 1 00:00:00
ANSI C strptime format t
POSIX strptime "%Z" GNU C
-1

seconds("Mar0211:12:36AMPST2007","%b%d%rPST%Y");
seconds(time("%b%d%r%z%Y"),"%b%d%r%z%Y");
seconds(time("%b%d%r%Z%Y"),"%b%d%r"+time("%Z")+"%Y");
1+(seconds()-seconds("Jan1","%b%d"))/(24*60*60);

string time(int seconds, string format="%a%b%d%T%Z%Y")


UTC 1970 1 1 00:00:00 seconds
ANSI C strftime format
24

time(seconds()-24*60*60);

void abort(string s)
s
s
%a %A
%b %B
%c %C 100
%d 0131 %D %m/%d/%y
%e 131 %F %Y-%m-%d ISO 8601
%g ISO 8601 0099 %G
%h %b %H 24 0023
%I 12
0112 %j 001366
%m 0112 %M 0059
%n %p AM PM
%r 12 %R %H:%M
%S 0060 %t
%T %H:%M:%S ISO 8601 %u 17 1
%U 0053 %w 06 0
%W 0053 %V ISO 8601 0153
%x %X
%y 0099 %Y
%z UTC ISO 8601 %% %
"+0800" UTC
8 0

9
(int)time("%j")
5.2 PATHGUIDE 25

void exit()
10

void sleep(int seconds)


void usleep(int microseconds)


void beep()

C/C++ typedef 11 63 5.11

5.2 pathguide
path nullpath
circle(pair c, real r) c r Bzier
unitcircle 1 12

path circle(pair c, real r)


{
return shift(c)*scale(r)*unitcircle;
}

graph.asy Circle 13

import graph;
path Circle(pair c, real r, int n=nCircle);

circle c r angle1 angle2 angle2 > angle1


path arc(pair c, real r, real angle1, real angle2);


10

11
typedef new

12
unitcircle

path unitcircle=E..N..W..S..cycle;

4 (1,0)
13
nCircle graph nCircle 400
0.06%
nCircle

26

path arc(pair c, real r, real angle1, real angle2, bool direction);

direction CCWcounter-clockwise CWclockwise


z1 z2 c 14 |z2 c| = |z1 c|

path arc(pair c, explicit pair z1, explicit pair z2,


bool direction=CCW)

graph.asy n Bzier

import graph;
path Arc(pair c, real r, real angle1, real angle2, bool direction,
int n=nCircle);
path Arc(pair c, real r, real angle1, real angle2, int n=nCircle);
path Arc(pair c, explicit pair z1, explicit pair z2,
bool direction=CCW, int n=nCircle);

path ellipse(pair c, real a, real b)


{
return shift(c)*scale(a,b)*unitcircle;
}

size(300,0);
pair[] z=new pair[10];

z[0]=(0,100); z[1]=(50,0); z[2]=(180,0);

for(int n=3; n <= 9; ++n)


z[n]=z[n-3]+(200,0);

path p=z[0]..z[1]---z[2]::{up}z[3]
&z[3]..z[4]--z[5]::{up}z[6]
&z[6]::z[7]---z[8]..{up}z[9];

14
plain c z1 z2 c c z1

5.2 PATHGUIDE 27

draw(p,grey+linewidth(4mm));

dot(z);

int length(path p);


p p p

int size(path p);


p p length(p)

bool cyclic(path p);


true p 15

bool straight(path p, int i);


true p i i+1

bool piecewisestraight(path p);


true p

pair point(path p, int t);


p t mod length(p) t
t < 0 point(0) t > length(p) point(length(p))

pair point(path p, real t);


floor(t) floor(t)+1 t-floor(t)
Bzier t [0, length(p)]
p length(p) p p

pair dir(path p, int t, int sign=0, bool normalize=true);


15

28

sign < 0 p t
sign > 0 sign = 0

pair dir(path p, real t, bool normalize=true);


p floor(t) floor(t)+1 t-floor(t)
Bzier

pair accel(path p, int t, int sign=0);


sign < 0 p t
sign > 0 sign = 0

pair accel(path p, real t);


p t

pair radius(path p, real t);


p t 16

pair precontrol(path p, int t);


p t

pair precontrol(path p, real t);


p t

pair postcontrol(path p, int t);


p t

pair postcontrol(path p, real t);


p t

real arclength(path p);


p

real arctime(path p, real L);


17 0 point(path p, real t)
L

real dirtime(path p, pair z);


0 point(path, real)
z -1
16

17

5.2 PATHGUIDE 29

real reltime(path p, real l);


p l

pair relpoint(path p, real l);


p l

pair midpoint(path p);


p

path reverse(path p);


p

path subpath(path p, int a, int b);


p a b a < b

path subpath(path p, real a, real b);


p a b a < b

real[] intersect(path p, path q, real fuzz=-1);


p q 2
The METAFONTbook 137 18
point(path p, real t) p q fuzz
fuzz < 0
0

real[][] intersections(path p, path q, real fuzz=-1);


69 5.12 2 p
q fuzz
fuzz < 0

real[] intersections(path p, explicit pair a, explicit pair b, real fuzz=-1);


p ab
fuzz fuzz < 0

real[] times(path p, real x)


18
p q m n m n
p q (u, v) (.t1 t2 . . .)2
(.u1 u2 . . .)2 (.t1 u1 t2 u2 . . .)2 (u, v)


30

p (x,0)

real[] times(path p, explicit pair z)


p (0,z.y)

real[] mintimes(path p)
2 p

real[] maxtimes(path p)
2 p

pair intersectionpoint(path p, path q, real fuzz=-1);


point(p,intersect(p,q,fuzz)[0])

pair[] intersectionpoints(path p, path q, real fuzz=-1);


p q

pair extension(pair P, pair Q, pair p, pair q);


P--Q p--q (infinity,infinity)

slice cut(path p, path knife, int n);


slice

struct slice {
path before,after;
}

p knife n p
n

slice firstcut(path p, path knife);


cut(p,knife,0) firstcut.after METAPOST cutbefore

slice lastcut(path p, path knife);


cut(p,knife,-1) lastcut.before METAPOST cutafter

path buildcycle(... path[] p);


5.2 PATHGUIDE 31

METAPOST buildcycle 19

pair min(path p);


p (, )

pair max(path p);


p (, )

int windingnumber(path p, pair z);


p z 20 z
z p undefined

bool interior(int windingnumber, pen fillrule);


fillrule windingnumber true21

bool inside(path p, pair z, pen fillrule=currentpen);


true z p fillrule 34 5.3

int inside(path p, path q, pen fillrule=currentpen);


p fillrule 34 5.3 q 1
q p -1 0

pair inside(path p, pen fillrule=currentpen);


fillrule 34 5.3 p

path[] strokepath(path g, pen p=currentpen);


PostScript p g

19
METAPOST p1 , p2 , , pk pi pi+1 pi pi+1
METAPOST: A Users Manual 9.1 Building Cycles
20

= 2 = 1 = 0 = 1 = 2

H
= (t0 ) (0) = 1
2i
dz
C za
C : z = z(t), (t [0, t0 ]) z a
(r(t), (t))
21
fillrule zerowinding windingnumber != 0 fillrule evenodd
windingnumber%2 != 0 windingnumber
32

guide guide nullpath





size(200);

real mexican(real x) {return (1-8x^2)*exp(-(4x^2));}

int n=30;
real a=1.5;
real width=2a/n;

guide hat;
path solved;

for(int i=0; i < n; ++i) {


real t=-a+i*width;
pair z=(t,mexican(t));
hat=hat..z;
solved=solved..z;
}

draw(hat);
dot(hat,red);
draw(solved,dashed);

guide g;
for(int i=0; i < 10; ++i)
5.2 PATHGUIDE 33

g=g--(i,i);
path p=g;

path p;
for(int i=0; i < 10; ++i)
p=p--(i,i);

int size(guide g);


size(path p)

int length(guide g);


length(path p)

bool cyclic(path p);


cyclic(path p)

pair point(guide g, int t);


point(path p, int t)

guide reverse(guide g);


reverse(path p) g
g

pair[] dirSpecifier(guide g, int i);


2 g i i+1
0 122 (0,0)

pair[] controlSpecifier(guide g, int i);


g i i+1 23
0 1
22
z1 {d1} .. {d2} z2 d1 d2 1
23
z1 .. controls c1 and c2 .. z2 c1 c2 z1 .. controls c .. z2
z1 .. controls c and c .. z2
34

tensionSpecifier tensionSpecifier(guide g, int i);


g i i+1 tensionSpecifier
inout atLeast 24

real[] curlSpecifier(guide g);


g 0
1 25

nullpath

a..{up}nullpath..b;
c..nullpath{up}..d;
e..{up}nullpath{down}..f;

a..nullpath..{up}b;
c{up}..nullpath..d;
e{down}..nullpath..{up}f;

5.3
Asymptote 7

currentpen METAPOST
pickup defaultpen
+
dashed+red+green red+green+dashed
red+dashed+green *
1 26

pen gray(real g);


g [0, 1] 0.0 1.0
24
z1 .. tension t1 and t2 .. z2 in out t1 t2 atLeast false
z1 .. tension atleast t1 and t2 .. z2 atLeast true z1 .. tension t .. z2
z1 .. tension t and t .. z2 tensionSpecifier tens z1 .. tens .. z2
25
z1 {curl c1} .. {curl c2} z2 c1 c2
26
1
5.9.1 interp(T a, T b, real t)
LATEX xcolor
5.3 35

pen rgb(real r, real g, real b);

RGB 27 [0, 1]

pen cmyk(real c, real m, real y, real k);

CMYK 28 [0, 1]

pen invisible;

TEX
\phantom bool invisible(pen)

black defaultpen(pen) colorspace(pen p)


p "gray""rgb" "cmyk" ""

real[] colors(pen) pen gray(pen) pen rgb(pen)


pen cmyk(pen) colorless(pen=currentpen)

6 RGB

pen rgb(string s);

plain black white


RGB redgreen blue RGB cyan
magenta yellow CMYK CyanMagentaYellowBlack

27
redgreenblue
28
cyanmagentayellow black
36

palered palecyan black


lightred lightcyan white
mediumred mediumcyan
red cyan orange
heavyred heavycyan fuchsia
brown deepcyan
darkbrown darkcyan chartreuse
springgreen
palegreen pink
lightgreen lightmagenta purple
mediumgreen mediummagenta royalblue
green magenta
heavygreen heavymagenta Cyan
deepgreen deepmagenta Magenta
darkgreen darkmagenta Yellow
Black
paleblue paleyellow
lightblue lightyellow cmyk(red)
mediumblue mediumyellow cmyk(blue)
blue yellow cmyk(green)
heavyblue lightolive
deepblue olive
darkblue darkolive
palegray
lightgray
mediumgray
gray
heavygray
deepgray
darkgray

140 RGB X11

import x11colors;

68 CMYK TEX

import texcolors;

Green
Asymptote asycolors.sty LATEX LATEX CMYK Asymptote
LATEX LATEX
7.17 slide 29
LATEX Asymptote LATEX

usepackage("asycolors");

plain_pens.asy hsv HSVHue Saturation Value


RGB h [0, 360) s v [0, 1]

pen p=hsv(180,0.5,0.75);
29

5.3 37

write(p); // ([default], red=0.375, green=0.75, blue=0.75)


hsv q=p;
write(q.h,q.s,q.v); // 180 0.5 0.75

pen linetype(string s, real offset=0, bool scale=true, bool adjust=true)


s offset
scale true
PostScript adjust
true Asymptote

pen solid=linetype("");
pen dotted=linetype("04");
pen dashed=linetype("88");
pen longdashed=linetype("248");
pen dashdotted=linetype("8808");
pen longdashdotted=linetype("24808");
pen Dotted=dotted+1.0;
pen Dotted(pen p=currentpen) {return dotted+2*linewidth(p);}

solid defaultpen(pen)

pen linewidth(real) PostScript 30 0.5 dp


defaultpen(pen) real linewidth(pen p=currentpen)
plain

static void defaultpen(real w) {defaultpen(linewidth(w));}


static pen operator +(pen p, real w) {return p+linewidth(w);}
static pen operator +(real w, pen p) {return linewidth(w)+p;}

defaultpen(2);
pen p=red+0.5;

PostScript linecap 31
30
Asymptote PostScript
31
line cap PostScript
38

pen squarecap=linecap(0);
pen roundcap=linecap(1);
pen extendcap=linecap(2);

roundcap defaultpen(pen) int linecap(pen p=currentpen)


PostScript linejoin 32

pen miterjoin=linejoin(0);
pen roundjoin=linejoin(1);
pen beveljoin=linejoin(2);

roundjoin defaultpen(pen) int linejoin(pen p=curren


PostScript miter limit miterlimit(real)


10.0 defaultpen(pen) real miterlimit(pen p=currentpen)

PostScript fillrule

pen zerowinding=fillrule(0);
pen evenodd=fillrule(1);

clip fill inside


zerowinding z--z+infinity
z evenodd
z zerowinding defaultpen(pen)
int fillrule(pen p=currentpen)

basealign

pen nobasealign=basealign(0);
pen basealign=basealign(1);
squarecap
roundcap
extendcap

32
PostScript

miterjoin roundjoin beveljoin

5.3 39

nobasealign defaultpen(pen)
baseline TEX int basealign(pen p=currentpen)

pen fontsize(real size, real lineskip=1.2*size) TEX 1 pt =


1/72.27 12 pt defaultpen(pen)

import fontsize;

x-cm http://www.ctan.org/tex-archive/help/Catalogue/entries/
fix-cm LATEX
real fontsize(pen p=currentpen) real lineskip(pen p=currentpen)

LATEX NFSS

pen font(string encoding, string family, string series, string shape)

font("OT1","cmr","m","n") 12 pt Computer Modern Roman


defaultpen(pen) string font(pen p=currentpen)
unicode 7.19 unicode 33
pen font(string name) TEX fontsize
"cmr12"12 pt Computer Modern Roman pcrrCourier
pen font(string name, real size)
pen fontcommand(string)
PostScript

pen AvantGarde(string series="m", string shape="n");


pen Bookman(string series="m", string shape="n");
pen Courier(string series="m", string shape="n");
pen Helvetica(string series="m", string shape="n");
pen NewCenturySchoolBook(string series="m", string shape="n");
pen Palatino(string series="m", string shape="n");
pen TimesRoman(string series="m", string shape="n");
pen ZapfChancery(string series="m", string shape="n");
pen Symbol(string series="m", string shape="n");
pen ZapfDingbats(string series="m", string shape="n");

pen opacity(real opacity=1, string blend="Compatible");


33

40

opacity 0 1 blend
-

"Compatible","Normal","Multiply","Screen","Overlay","SoftLight",
"HardLight","ColorDodge","ColorBurn","Darken","Lighten","Difference",
"Exclusion","Hue","Saturation","Color","Luminosity"

http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf

PostScript -f pdf PDF


ImageMagick convert opacity 1
transparency.asy 34

picture PostScript name


PostScript currentpatterns fill draw lb
rt

import patterns;
void add(string name, picture pic, pair lb=0, pair rt=0);

name fill draw pattern("name")


patternss.asy

picture tile(real Hx=5mm, real Hy=0, pen p=currentpen,


filltype filltype=NoFill);
picture checker(real Hx=5mm, real Hy=0, pen p=currentpen);
picture brick(real Hx=5mm, real Hy=0, pen p=currentpen);

size(0,90);
import patterns;

34

size(0,150);

settings.outformat="pdf";

begingroup();
fill(shift(1.5dir(120))*unitcircle,green+opacity(0.75));
fill(shift(1.5dir(60))*unitcircle,red+opacity(0.75));
fill(unitcircle,blue+opacity(0.75));
endgroup();

5.3 41

add("tile",tile());
add("filledtilewithmargin",tile(6mm,4mm,red,Fill),(1mm,1mm),(1mm,1mm));
add("checker",checker());
add("brick",brick());

real s=2.5;
filldraw(unitcircle,pattern("tile"));
filldraw(shift(s,0)*unitcircle,pattern("filledtilewithmargin"));
filldraw(shift(2s,0)*unitcircle,pattern("checker"));
filldraw(shift(3s,0)*unitcircle,pattern("brick"));

picture hatch(real H=5mm, pair dir=NE, pen p=currentpen)


picture crosshatch(real H=5mm, pen p=currentpen)

size(0,100);
import patterns;

add("hatch",hatch());
add("hatchback",hatch(NW));
add("crosshatch",crosshatch(3mm));

real s=1.25;
filldraw(unitsquare,pattern("hatch"));
filldraw(shift(s,0)*unitsquare,pattern("hatchback"));
filldraw(shift(2s,0)*unitsquare,pattern("crosshatch"));
42

PostScript patterns.asy
9 4.2
35

size(0,100);
import patterns;

real d=4mm;
picture tiling;
path square=scale(d)*unitsquare;
axialshade(tiling,square,white,(0,0),black,(d,d));
fill(tiling,shift(d,d)*square,blue);
add("shadedtiling",tiling);

filldraw(unitcircle,pattern("shadedtiling"));

pen makepen(path)
path nib(pen)
METAPOST

size(200);
pen convex=makepen(scale(10)*polygon(8))+grey;
draw((1,0.4),convex);
draw((0,0)---(1,1)..(2,0)--cycle,convex);

pen nonconvex=scale(10)*
makepen((0,0)--(0.25,-1)--(0.5,0.25)--(1,0)--(0.5,1.25)--cycle)+red;
draw((0.5,-1.5),nonconvex);
draw((0,-1.5)..(1,-0.5)..(2,-1.5),nonconvex);

35
PostScript 3

5.3 43

nullpath
yscale(2)*currentpen

overwrite

Allow

defaultpen(pen)

Suppress

SuppressQuiet

Move


PostScript

MoveQuiet


PostScript

defaultpen() resetdefaultpen()

44

5.4
Asymptote (x,y) t=(t.x,t.y,t.xx,t.xy,t.yx,t.yy)
(x',y')

x'=t.x+t.xx*x+t.xy*y
y' = t.y + t.yx * x + t.yy * y

PostScript [t.xx t.yx t.xy t.yy t.x t.y]


*
25 5.2 transform inverse(transform t)
^ 36

transform identity();

transform shift(pair z);


z

transform shift(real x, real y);


(x,y)

transform xscale(real x);


x x

transform yscale(real y);


y y

transform scale(real s);


x y s

transform scale(real x, real y);


x x y y

transform slant(real s);


(x, y) 7 (x + s y, y)

transform rotate(real angle, pair z=(0,0));


z angle

transform reflect(pair a, pair b);


a--b
36
n n > 0 n n n

5.5 FRAMEPICTURE 45

identity() shift(transform t) shiftless(transform t)


(t.x,t.y,0,0,0,0) (0,0,t.xx,t.xy,t.yx,t.yy)37

5.5 framepicture
frame frame PostScript
picture newframe f
bool empty(frame f) true erase(frame)
pair min(frame) pair max(frame) (, ) (, )

void add(frame dest, frame src);

src dest

void prepend(frame dest, frame src);

38
label align 12 4.4 f align

frame align(frame f, pair align);


envelope
39

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);
37

Asymptote xxxy

shift(x,y) * (rotate(90)*scale(yx,-xy) + scale(xx,yy))


// (x, y, xx, xy, yx, yy)


38

39
f f L

46

picture plain 55 5.8


currentpicture

picture pic;

new picture
size

void size(picture pic=currentpicture, real x, real y=x,


bool keepAspect=Aspect);

x y 0 PostScript pic
identity()
x y 0
keepAspect Aspect true x
y
keepAspect IgnoreAspect false x
y
pic x x y y

void unitsize(picture pic=currentpicture, real x, real y=x);

x y pic

void size(picture pic=currentpicture, real xsize, real ysize,


pair min, pair max);

box(min,max) xsize ysize



transform fixedscaling(picture pic=currentpicture, pair min,


pair max, pen p=nullpen, bool warn=false);

pic box(min,max)
p
shipout pic format prefix.fotmat

void shipout(string prefix=defaultfilename, picture pic=currentpicture,


orientation orientation=orientation,
5.5 FRAMEPICTURE 47

string format="", bool wait=false, bool view=true,


string options="", string script="",
projection P=currentprojection);

PostScript -f -tex options, script


projection 3D defaultfilename outprefix()

shipout() shipout()

Portrait orientation
orientation=Landscape

shipout(Landscape);

90 Seascape 180 UpsideDown

pic

frame pic.fit(real xsize=pic.xsize, real ysize=pic.ysize,


bool keepAspect=pic.keepAspect);

size 0, 0 true pic


pic.calculateTransform()

pic 2D

frame pic.scale(real xsize=this.xsize, real ysize=this.ysize,


bool keepAspect=this.keepAspect);

frame bbox(picture pic=currentpicture, real xmargin=0,


real ymargin=xmargin, pen p=currentpen,
filltype filltype=NoFill);

filltype

FillDraw

FillDraw(real xmargin=0, real ymargin=xmargin, pen fillpen=nullpen,


pen drawpen=nullpen);
48

fillpen nullpen fillpen


drawpen nullpen fillpen drawpen
xmargin ymargin

Fill

Fill(real xmargin=0, real ymargin=xmargin, pen p=nullpen)


p nullpen p
xmargin ymargin

NoFill
.

Draw

Draw(real xmargin=0, real ymargin=xmargin, pen p=nullpen)


p nullpen p
xmargin ymargin

UnFill
40

UnFill(real xmargin=0, real ymargin=xmargin)


xmargin ymargin

RadialShade(pen penc, pen penr)


penc penr

0.25 cm

shipout(bbox(0.25cm));

bbox(p,Fill) p

pair min(picture pic, user=false);


pair max(picture pic, user=false);
pair size(picture pic, user=false);
40
clip UnFill clip
5.5 FRAMEPICTURE 49

pic PostScript user


false PostScript

pair point(picture pic=currentpicture, pair dir, bool user=true);

pic dir
user false PostScript

pair truepoint(picture pic=currentpicture, pair dir, bool user=true);

point pic
user false PostScript
add

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);

src currentpicture src destgroup


xasy src 10 GUI41 filltype
above src
PostScript src position
dest currentpicture

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);

42 align label align


12 4.4 align
41

42

plain_picture
50

position 7.25 graph errorbars image


43

picture pic1;
real size=50;
size(pic1,size);
fill(pic1,(0,0)--(50,100)--(100,0)--cycle,red);

picture pic2;
size(pic2,size);
fill(pic2,unitcircle,green);

picture pic3;
size(pic3,size);
fill(pic3,unitsquare,blue);

picture pic;
add(pic,pic1.fit(),(0,0),N);
add(pic,pic2.fit(),(0,0),10S);

add(pic.fit(),(0,0),N);
add(pic3.fit(),(0,0),10S);

attach dest position src

void attach(picture dest=currentpicture, frame src,


43

5.5 FRAMEPICTURE 51

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);

currentpicturecurrentpen currentprojection save()


currentpicturecurrentpen currentprojection restore()44
plain 45
PostScript
void postscript(picture pic=currentpicture, string s);
void postscript(picture pic=currentpicture, string s, pair min,
pair max)

min max PostScript


TEX LATEX
void tex(picture pic=currentpicture, string s);
void tex(picture pic=currentpicture, string s, pair min, pair max);

min max TEX


TEX 46 TEX TEX

void texpreamble(string s);

TEX 47
void texreset();


void usepackage(string s, string options="");


texpreamble("\usepackage["+options+"]{"+s+"}");

LATEX
44
save() restore
45
plain
46

47

52

5.6
Asymptote CSV XDR External Data Repre-
sentation
input(string name, bool check=true, string comment="#")

file fin=input("test.txt");
real a=fin;

check false
bool error(file) true comment

-globalwrite -nosafe string cd(string s)


s string s

Asymptote string getc(file)

name

file output(string name, bool update=false);

update=false
update=true
-globalwrite -nosafe

stdin stdout
null
T

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);

file stdout
s x suffix
none flushendl
5.6 53

newl tab comma

file fout=output("test.txt");
write(fout,1); // "1"
write(fout); //
write(fout,"List:",1,2,3); // "List: 1 2 3"

xinput xoutput input output Sun Microsystem


XDRExternal Data Representation UNIX
64 32 binput boutput
file single(file,0.0)
XDR file single(file,0.0,false)
file single(file,0) file single(file,0,false)
file single(file) file single(file,false)

eof(file) eol(file) error(file)


I/O flush(file) clear(file) I/O
close(file) digits int precision(file file=stdout, int digits=0)
file digits int tell(file)
seek(file file, int pos) pos
seek(file,0) seek(file,-1)
seekeof(file)
settings.scroll=n n stdout n
n s q
n
settings.scroll=0
plain

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);
54

stdin GNU readline store=true name


".asy_history_" + name 48
default prompt

string readline(string prompt="", string name="", bool tabcompletion=false);


void saveline(string name, string value, bool store=true);

readline prompt saveline


value name
".asy_history_" + name
history(string name, int n=1) name n
historylines n=0 history(int n=0)

write(output("transcript.asy"),history());

transcript.asy
int delete(string s) s -globalwrite -nosafe
int rename(string from, string to)
from to -globalwrite -nosafe

int convert(string args="", string file="", string format="");


int animate(string args="", string file="", string format="");

ImageMagick convert animate args file format


49 safe int system(string s) s

5.7
int x=3; x 3 3
real x=2*sin(pi/2);

int x=2;
int x=5*x;

x x x
x 10

int, real pair triple O=(0,0,0)


48
9 Interactive mode
49
ImageMagick Windows FAT
NTFS convert
5.8 55

bool false

string

transform

path guide nullpath

pen

frame picture

file null

code

T T operator init() int

int operator init() {


return 3;
}
int y;

y 3
operator init

5.8
C++
public restricted
private
this

50 51

struct T {
int x;
}
T foo=new T;
T bar=foo;
bar.x=5;
50
C/C++
51
C/C++
56

foo T bar foo foo


bar.x=5 x foo.x 5
new T T

int Tcount=0;
struct T {
int x;
++Tcount;
}

T foo=new T;

new T Tcount
52
null

bool alias(T,T) null


alias(foo,bar) alias(foo,new T) new T
T == != alias !alias
53
T T new T
T null

struct tree {
int value;
tree left;
tree right;
}

struct S {
real a=1;
real f(real a) {return a+this.a;}
}

S s; // new S s
52
Tcount T 82 5.15
53

5.8 57

write(s.f(2)); // 3

S operator + (S s1, S s2)


{
S result;
result.a=s1.a+s2.a;
return result;
}

write((s+s).f(0)); // 2

Person

struct Person {
string firstname;
string lastname;
}

Person joe=new Person;


joe.firstname="Joe";
joe.lastname="Jones";

Person

Person(string,string)

struct Person {
string firstname;
string lastname;

static Person Person(string firstname, string lastname) {


Person p=new Person;
p.firstname=firstname;
p.lastname=lastname;
return p;
}
}

Person joe=Person.Person("Joe", "Jones");


58

Person.Person

from Person unravel Person;

Person joe=Person("Joe", "Jones");



Asymptote

Asymptote void operator init(args)


args
Foo

static Foo Foo(args) {


Foo instance=new Foo;
instance.operator init(args);
return instance;
}


Person

struct Person {
string firstname;
string lastname;

void operator init(string firstname, string lastname) {


this.firstname=firstname;
this.lastname=lastname;
}
}

Person joe=Person("Joe", "Jones");

operator init 54 5.7


operator init void
void
cputime() cputime CPU parent.user,
parent.system, child.user child.system change.user change.system
CPU cputime()

void write(file file=stdout, string s="", cputime c,


string format=cputimeformat, suffix suffix=none);
5.8 59

CPU u CPU s CPU


U CPU S
C++ 78 5.13 54
55

struct parent {
real x;
void operator init(int x) {this.x=x;}
void virtual(int) {write(0);}
void f() {virtual(1);}
}

void write(parent p) {write(p.x);}

struct child {
parent parent;
real y=3;
void operator init(int x) {parent.operator init(x);}
void virtual(int x) {write(x);}
parent.virtual=virtual;
void f()=parent.f;
}

parent operator cast(child child) {return child.parent;}

parent p=parent(1);
child c=child(2);

write(c); // 2;

p.f(); // 0;
c.f(); // 1;

write(c.parent.x); // 2;
write(c.y); // 3;

54
C++

55
C++
child parent unravel parent; parent.x parent
_f(parent obj=this, int) virtual(int) this
60

Asymptote plain Legend picture

5.9
5.9.1
Asymptote
int quotient(int x, int y)
x/y

+
-
*
/
% p q
q*quotient(p,q)+p%q == p
^
** ^

56

==
!=
<
<=
>=
>
&& 57
&
||
|
^
!

Asymptote C

bool positive=(pi >= 0) ? true : false;


56
bool C/C++ 0 bool
3 && 5 3!=0 && 5!=0
57

5.9 61

T interp(T a, T b, real t) T (1-t)*a+t*b a


b pen
Asymptote int AND(int,int), int OR(int,int), int XOR(int,int)
int NOT(int)

5.9.2
C +, -, *, /, % ^ ++
--

int i=1;
i += 2;
int j=++i;

int i=1;
i=i+2;
int j=i=i+1;

i++ i-- --
i++ i-- (++i-1) (--i+1)

5.9.3
operator

- + * / % ^ ! < > == != <= >= & | ^^ .. :: -- --- ++


<< >> $ $$ @ @@

<, >, <= >= 58


..

guide dots(... guide[] g)=operator ..;

guide operator ..(... guide[] g) {


guide G;
if(g.length > 0) {
write(g[0]);
G=g[0];
58

C/C++ ++, --
C/C++ sizeof
[] ** ^
62

}
for(int i=1; i < g.length; ++i) {
write(g[i]);
write();
G=dots(G,g[i]);
}
return G;
}

guide g=(0,0){up}..{SW}(100,100){NE}..{curl 3}(50,50)..(10,10);


write("g=",g);

5.10

int x=2;
real y=2.0;
real cm=72/2.540005;

write(3x);
write(2.5x);
write(3y);
write(-1.602e-19 y);
write(0.5(x,y));
write(2x^2);
write(3x+2y);
write(3(x+2y));
write(3sin(x));
write(3(sin(x))^2);
write(10cm);

6
5
6
-3.204e-19
(1,1)
8
5.11 63

10
18
2.72789228047704
2.48046543129542
283.464008929116

5.11
Asymptote

55
5.8
Asymptote

1.

int x, x();
x=5;
x=new int() {return 17;};
x=x(); // x() 17 x

2.

int sqr(int x)
{
return x*x;
}
sqr=null; //

3.

int a, a(), b, b(); //


a=b; //
a=(int) b; //
(int) (a=b); //
(int) a=b; //

int c();
c=a; //

4.
64

typedef int intop(int);


intop adder(int m)
{
return new int(int n) {return m+n;};
}
intop addby7=adder(7);
write(addby7(1)); // 8

5. f
f f
59

void f() {
write("hi");
}

void g() {
f();
}

g(); // "hi"

f=new void() {write("bye");};

g(); // "bye"

void f() {write("overloaded");};

f(); // "overloaded"
g(); // "bye"

6. null

void f(bool b);

void g(bool b) {
59
operator init()
null f g f g f f
g
5.11 65

if(b) f(b);
else write(b);
}

f=new void(bool b) {
write(b);
g(false);
};

g(true); // true, false.

Asymptote
C++
GNU libsigsegv 2.4

5.11.1

Asymptote C++
78 5.13

real f(int a=1, real b=0) {return a+b;}

f(1) 1.0 f(1.0) 2.0


Asymptote

5.11.2


C C++
-d Asymptote

int f(int x, int y) {


return 10x+y;
}
write(f(4,x=3));

34 4 x y
66

int x;
write(f(4,(x=3)));

int x;
x=3;
write(f(4,3));

43

int f(int x, int x()) {


return x+x();
}
int seven() {return 7;}

Asymptote f(2,seven) 9
f(x=2,x=seven) f(x=seven,2)
int() int f

int f(int x=3, int x()) {


return x+x();
}

f(x=seven) f(seven)

5.11.3

//
int sum(... int[] nums) {
int total=0;
for(int i=0; i < nums.length; ++i)
total += nums[i];
return total;
}

sum(1,2,3,4); // 10
sum(); // 0
5.11 67

//
int subtract(int start ... int[] subs) {
for(int i=0; i < subs.length; ++i)
start -= subs[i];
return start;
}

subtract(10,1,2); // 7
subtract(10); // 10
subtract(); //

subtract

int subtract(int start ... int[] subs) {


return start - sum(... subs);
}

sum(1,2,3 ... new int[] {4,5,6}); // 21

nums sum

subtract(... new int[] {10, 1, 2});

null 60

Asymptote C++

int f(path g);


int f(guide g);
f((0,0)--(100,100)); // guide

int g(int x, real y);


int g(real x, int x);

60
empty arraynull array 69 5.12
null C/C++
68

g(3,4); //
//

int h(... int[] rest);


int h(real x ... int[] rest);

h(1,2); //
//

int i(int x ... int[] rest);


int i(real x, real y ... int[] rest);

i(3,4); //
//

5.11.4
Asymptote libm real(real) sin, cos, tan, asin, acos, atan,
exp, log, pow10, log10, sinh, cosh, tanh, asinh, acosh, atanh, sqrt, cbrt, fabs, expm1, log1p
identity61 Asymptote n Bessel J(int n, real)
Y(int n, real) gamma erf erfc
real(real, real) atan2, hypot, fmod, remainder62
degrees(real radians) radians(real degrees)
Degrees(real radians) [0, 360) Asymptote
Sin, Cos, Tan, aSin, aCos aTan sqrt, sin, cos, exp,
log gamma
floor, ceil round63
Floor, Ceil Round
intMax intMin
sgn1, 0 1
abs(int) abs(real) fabs(real) abs(pair)
length(pair)
srand(int) int rand() 0 randMax
61
sin cos tan asin acos atan exp
log e pow10 log10 10 sinh cosh tanh asinh
acosh atanh sqrt cbrt fabs expm1 x 7 exp x 1
log1p x 7 log(1 + x) identity
62
p
atan2(real y, real x) y/x hypot(real x, real y) x2 + y 2 fmod remainder

63
floor xceil x round
5.12 69

unitrand() [0, 1] Gauss Gaussrand


histogram stats.asy 64
65 factorial(int n) n! choose(int n, int k) n!/(k!(n k))!
GNU GNU Scientic Library, GSL http://www.gnu.
org/software/gsl/ Asymptote gsl Airy Ai(real),
Bi(real), Ai_deriv(real), Bi_deriv(real), zero_Ai(int), zero_Bi(int), zero_Ai_deriv(int),
zero_Bi_deriv(int) Bessel I(int, real), K(int, real), j(int, real), y(int, real),
i_scaled(int, real), k_scaled(int, real), J(real, real), Y(real, real), I(real, real),
K(real, real) , zero_J(real, int) F(real, real), E(real, real) P(real, real)
/ Ei, Si Ci Legendre Pl(int, real) Riemann zeta(real)
1.0 Si

import gsl;
write(Si(1.0));

Asymptote

real newton(int iterations=100, real f(real), real fprime(real), real x,


bool verbose=false);

fprime x Newton-Raphson f
verbose=trueiterations
realMax

real newton(int iterations=100, real f(real), real fprime(real), real x1,


real x2, bool verbose=false);

fprime Newton-Raphson bracketed Newton-Raphson bisec-


tion [x1, x2] f f
verbose=trueiterations
realMax

real simpson(real f(real), real a, real b, real acc=realEpsilon, real dxmax=b-a)


Simpson f a b

5.12
[] A i A[i]

64
stats.asy
65
int

70

B A A[B] A B
Java 17 66

real[] A;

A empty array null array

real[] A=null;

real[] A={0,1,2};

Asymptote
copy
T[] A

int length

void cyclic(bool b)

bool cyclicflag

int[] keys

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()

bool initialized(int n)

A.length A.cyclic(true)
cyclic
A.cyclicflag cyclic
A.keys
n A.keys 0 n-1 A.keys
key
66
for (elem : array) { statements }
5.12 71

A.push A.append A.insert(int i ... T[] x) x


i A.push A.pop()
A.delete(int i, int j=i) [i, j]
A.delete() A A.initialized(int n)
n Asymptote cyclic, push, append, pop,
insert, delete initialized

int[] A={1};
A.push(2); // A {1,2}
A.append(A); // A {1,2,1,2}
int f(int)=A.push;
f(3); // A {1,2,1,2,3}
int g()=A.pop;
write(g()); // 3
A.delete(0); // A {2,1,2}
A.delete(0,1); // A {2}
A.insert(1,3); // A {2,3}
A.insert(1 ... A); // A {2,2,3,3}
A.insert(2,4,5); // A {2,2,4,5,3,3}

[]

real a,A[];

a real A real[]
T alias, array, copy, concat,
sequence, map transpose T T[]

new T[]
T[]

new T[] {list}


T[] list

new T[n]
n n

T[] array(int n, T value, int depth=intMax)


value n value
depth

int[] sequence(int n)
72

n >= 1 {0,1,...,n-1}

int[] sequence(int n, int m)


m >= n {n,n+1,...,m}

T[] sequence(T f(int), int n)


T f(int) int n n >= 1 {f(i) : i=0,1,...,n-1}

T[] map(T f(T), T[] a)


f a
sequence(new T(int i) {return f(a[i]);}, a.length)

int[] reverse(int n)
n >= 1 {n-1,n-2,...,0}

int[] complement(int[] a, int n)


a {0,1,2,...,n-1} b[complement(a,b.length)]
b[a]

real[] uniform(real a, real b, int n)


n >= 1 [a, b] n 67

int find(bool[], int n=1)


n true -1 n
-n

int search(T[] a, T key)


T n a key key
-1 n-1

T[] copy(T[] a)
a

T[][] copy(T[][] a)
a

T[][][] copy(T[][][] a)
a

T[] concat(... T[][] a)


bool alias(T[] a, T[] b)


67
n+1
5.12 73

a b 68 true

T[] sort(T[] a)
T a 69

T[][] sort(T[][] a)
T a

string[][] a={{"bob","9"},{"alice","5"},{"pete","7"},{"alice","4"}};
// 0 1
write(sort(a));

alice 4
alice 5
bob 9
pete 7

T[] sort(T[] a, bool compare(T i, T j))


a compare(i,j) i j

T[][] transpose(T[][] a)
a

T[][][] transpose(T[][][] a, int[] perm)


a 3 new int[]{0,1,2} perm 70

T sum(T[] a)
T a T bool a

T min(T[] a)
T min(T[][] a)
T min(T[][][] a)

T a

T max(T[] a)
T max(T[][] a)
T max(T[][][] a)
68

69
a

70
n S3
o ai1 ,i2 ,i3 0 6 i1 , i2 , i3 < n

ai(1) ,i(2) ,i(3) 0 6 i1 , i2 , i3 < n, S3
74

T a

T[] min(T[] a, T[] b)


T a b a b

T[] max(T[] a, T[] b)


T a b a b

pair[] pairs(real[] x, real[] y)


x y pair
sequence(new pair(int i) {return (x[i],y[i]);}, x.length)

pair[] fft(pair[] a, int sign=1)


a Fourier FFTW sign71

int n=4;
pair[] f=sequence(n);
write(f);
pair[] g=fft(f,-1);
write();
write(g);
f=fft(g,1);
write();
write(f/n);

real dot(real[] a, real[] b)


a b

real[] tridiagonal(real[] a, real[] b, real[] c, real[] f)


Lx = f x f n L n n

b0 c0 a0

a1 b1 c1


a2 b2 c2
..
..
.
..
. .

cn1 an1 bn1

Dirichlet u1 un f0 a0 u1 fn1 cn1 un f0


a0 = cn1 = 072
71
sign 1 Fourier sign +1 Fourier
72
a, b, c, f a, b, c, f
5.12 75

real[] solve(real[][] a, real[] b, bool warn=true)


LU ax = b x a n n b
n

import math;
real[][] a={{1,-2,3,0},{4,-5,6,2},{-7,-8,10,5},{1,50,1,-2}};
real[] b={7,19,33,3};
real[] x=solve(a,b);
write(a); write();
write(b); write();
write(x); write();
write(a*x);

a warn false a
tridiagonal tridiagonal

real[][] solve(real[][] a, real[][] b, bool warn=true)


ax = b x a n n b n m
a warn false

real[][] identity(int n)
n n

real[][] diagonal(... real[] a)


a

real[][] inverse(real[][] a)
a

real[] quadraticroots(real a, real b, real c)


ax2 + bx + c = 0

pair[] quadraticroots(explicit pair a, explicit pair b, explicit pair c)


ax2 + bx + c = 0

real[] cubicroots(real a, real b, real c, real d)


ax3 + bx2 + cx + d = 0

Asymptote
C++

real[] a={1,2};
real[] b={3,2};
76

a == b a >= 2 {false, true} a b


all(a == b) (a >= 2) ? a : b {3,2}
(a >= 2) ? a : null {2}
real(real) libm
map

file fin=input("test.txt");
real[] A=fin;
A I/O line(file)
line(file,false)
file fin=word(line(input("test.txt")));
real[] A=fin;
csv(file) csv(file,false)

file fin=csv(input("test.txt"));
real[] A=fin;
dimension(file,int)
file fin=input("test.txt");
real[] A=dimension(fin,10);
A 10
0


file fin=input("test.txt");
real[][] A=dimension(fin,2,3);
real[][][] B=dimension(fin,2,3,4);

read1, read2
read3
file fin=input("test.txt");
real[] A=read1(fin);
real[][] B=read2(fin);
real[][][] C=read3(fin);
write(file,T[]), write(file,T[][]), write(file,T[][][])

5.12 77

5.12.1
Asymptote Python slice A
A[m:n] A m n

int[] x={0,1,2,3,4,5,6,7,8,9};
int[] y=x[2:6]; // y={2,3,4,5};
int[] z=x[5:10]; // z={5,6,7,8,9};

int[] x={0,1,2,3,4,5,6,7,8,9};
int[] y=x[:4]; // y={0,1,2,3}
int[] z=x[5:]; // z={5,6,7,8,9}
int[] w=x[:]; // w={0,1,2,3,4,5,6,7,8,9}, x

A[m:n] [m, n)

int[] x={0,1,2,3,4,5,6,7,8,9};
x.cyclic(true);
int[] y=x[8:15]; // y={8,9,0,1,2,3,4}.
int[] z=x[-5:5]; // z={5,6,7,8,9,0,1,2,3,4}
int[] w=x[-3:17]; // w={7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6}

string[] toppings={"mayo", "salt", "ham", "lettuce"};


toppings[0:2]=new string[] {"mustard", "pepper"};
// toppings={"mustard", "pepper", "ham", "lettuce"}
toppings[2:3]=new string[] {"turkey", "bacon" };
// toppings={"mustard", "pepper", "turkey", "bacon", "lettuce"}
toppings[0:3]=new string[] {"tomato"};
// toppings={"tomato", "bacon", "lettuce"}
78

x[m:n]=x
x[m:n]=copy(x) x[m:m]=y x x[m]
y

A 10 A[8:12], A[-3:1] A[5:25]
A[3:7], A[7:10], A[-3:0] A[103:107]
A[0]

A A[A.length:A.length] A[0:0]
A.append()

5.13
Asymptote int realint pairreal pairpair pathpair guide
path guideguide pathreal penpair[] guide[]pair[] path[]path
path[] guide path[] three.asy

explicit 0

int f(pair a) {return 0;}


int f(explicit real x) {return 1;}

write(f(0));

real int real string

int i=(int) 2.5;


string s=(string) 2.5;

real[] a={2.5,-3.5};
int[] b=(int []) a;
write(stdout,b); // 2,-3

operator cast

struct rpair {
real radius;
real angle;
}
5.14 79

pair operator cast(rpair x) {


return (x.radius*cos(x.angle),x.radius*sin(x.angle));
}

rpair x;
x.radius=1;
x.angle=pi/6;

write(x); // (0.866025403784439,0.5)

100
100

real operator cast(int x) {return x*100;}

x*100 int
real

real convert(int x) {return x*100;}


real operator cast(int x)=convert;

operator ecast

5.14
Asymptote Asymptote

access graph;
graph.axes();

x y graph
graph

from graph access axes;

graph axes axes()

from graph access axes, xaxis, yaxis;

non-private

from graph access *;


80

unravel

struct matrix {
real a,b,c,d;
}

real det(matrix m) {
unravel m;
return a*d-b*c;
}

import graph;

access graph;
unravel graph;

import graph graph


Asymptote import

as

access graph as graph2d;


from graph access xaxis as xline, yaxis as yline;

import graph as graph2d;

access graph as graph2d;


unravel graph2d;

settings Asymptote
Asymptote 2.5 73


73

5.14 81

access "/usr/local/share/asymptote/graph.asy" as graph;


from "/usr/local/share/asymptote/graph.asy" access axes;
import "/usr/local/share/asymptote/graph.asy" as graph;


s Asymptote

eval("import"+s,true);

asy

void asy(string format, bool overwrite ... string[] s);

format overwrite true


s Asymptote

void eval(string s, bool embedded=false);

embedded true
embedded false settings
74
Asymptote

void eval(code s, bool embedded=false);

code quote {} Asymptote

real a=1;
code s=quote {
write(a);
};
eval(s,true); // 1

graph

include graph;
include "/usr/local/share/asymptote/graph.asy";

void list(string s, bool imports=false);

imports true
74

82

5.15 static

struct s {
int count() {
static int c=0;
++c;
return c;
}
}

s c count

int factorial(int n) {
int helper(int k) {
static int x=1;
x *= k;
return k == 1 ? x : helper(k-1);
}
return helper(n);
}

factorial helper x

struct A {
struct B {
static pair z;
}
}

A z

int pow(int n, int k) {


struct A {
static int x=1;
void helper() {
x *= n;
5.15 STATIC 83

}
}
for(int i=0; i < k; ++i) {
A a;
a.helper();
}
return A.x;
}

pow x

void f();
for(int i=0; i < 10; ++i) {
int x=i;
if(x==5) {
f=new void () { write(x); }
}
}
f();

x f() 5
static

void f() {
static int x;
for(int i=0; i < 10; ++i) {
static int y;
}
}

x y f

struct A {
static int x;
}
84

pair A;

int y=A.x;

A.x A Asymptote

!, 60, 61 <=, 60, 61


", 21 ==, 56, 60, 61
$, 61 >, 60, 61
$$, 61 >=, 60, 61
%, 60, 61 >>, 61
%=, 61 ? :, 60
&, 5, 60, 61 @, 61
&&, 60 @@, 61
', 21 [], 69, 71
*, 34, 44, 60, 61 ^, 44, 60, 61
**, 60, 61 ^=, 61
*=, 61 ^^, 5, 6, 61
+, 34, 60, 61
0, 54
++, 61
+=, 61 abort, 24
-, 60, 61 accel, 28
--, 3, 61 access, 79
---, 5, 61 acos, 68
-=, 61 acosh, 68
-V, 2 add, 40, 45, 49
-glo, 52, 54 alias, 56, 72
-nosafe, 52, 54 Align, 12
-o, 2 ailgn, 12
.., 3, 61 align, 14, 45
/, 60, 61 Allow, 43
/* */, 17 AND, 61
//, 17 angle, 19
/=, 61 animate, 54
::, 5, 61 append, 70
<, 60, 61 Arc, 26
<<, 61 arc, 25

85
86

ArcArrow, 7 beveljoin, 38
ArcArrows, 7 binput, 53
arclength, 28 Black, 35
arctime, 28 black, 35
array, 71 Blank, 7
Arrow, 7 blue, 35
arrow, 14 Bookman, 39
arrowhead, 7 bool, 18
arrowlength, 14 bool3, 18
Arrows, 7 boutput, 53
arrowsize, 7 box, 15, 45
as, 80 bp, 1
asin, 68 break, 17
asinh, 68 brick, 40
Aspect, 46 brown, 35
asy, 81 buildcycle, 30
asycolors.sty, 36 Bzier , 4
atan, 68 , 4
atan2, 68 , 4
atanh, 68
attach, 50 calculateTransform, 47
AvantGarde, 39 cast, 78
axialshade, 10 cbrt, 68
azimuth, 20 CCW, 26
cd, 52
Bars, 7 Center, 14
barsize, 7 change.system, 58
basealign, 38 change.user, 58
baseline, 14 chartreuse, 35
bbox, 47 checker, 40
beep, 25 child.system, 58
BeginArcArrow, 7 child.user, 58
BeginArrow, 7 Circle, 25
BeginBar, 7 circle, 25
BeginDotMargin, 8 clear, 53
BeginMargin, 8 clip, 12
BeginPenMargin, 8 close, 53
BeginPoint, 13 cm, 2
87

cmyk, 35 darkbrown, 35
CMYK , 35 darkcyan, 35
code, 55, 81 darkgray, 35
colatitude, 20 darkgreen, 35
colorless, 35 darkmagenta, 35
colors, 35 darkolive, 35
colorspace, 35 dashdotted, 37
comma, 52 dashed, 37
complement, 72 deepblue, 35
concat, 72 deepcyan, 35
conf, 18 deepgray, 35
continue, 17 deepgreen, 35
controls, 4 deepmagenta, 35
controlSpecifier, 33 Default, 7
convert, 54 default, 18
copy, 72 defaultformat, 9
cos, 68 defaultpen, 34, 35
cosh, 68 degrees, 19
Courier, 39 delete, 54, 70
cputime, 58 diagonal, 75
cross, 21 dimension, 76
crosshatch, 41 dir, 19, 20, 27, 28
CSV, 52 dirSpecifier, 33
csv, 76 dirtime, 28
cubicroots, 75 do, 17
curl, 5 dot, 9, 19, 21, 74
curlSpecifier, 34 dotfactor, 8
currentpen, 34, 51 DotMargin, 8
currentpicture, 51 DotMargins, 8
currentprojection, 51 Dotted, 37
CW, 26 dotted, 37
Cyan, 35 down, 3
cyan, 35 Draw, 7, 48
cycle, 3 draw, 7, 9, 11, 15
cyclic, 27, 33, 70
cyclicflag, 70 E, 3
ecast, 79
darkblue, 35 ellipse, 15, 26, 45
88

else, 17 filltype, 47
empty, 45 find, 22, 72
EndArcArrow, 7 firstcut, 30
EndArrow, 7 fit, 47
EndBar, 7 fixedscaling, 46
EndDotMargin, 8 flush, 52, 53
endl, 52 fmod, 68
EndMargin, 8 font, 39
EndPenMargin, 8 fontcommand, 39
EndPoint, 13 fontsize, 39
ENE, 3 fontsize.asy, 39
envelope, 15, 45 for, 17
eof, 53 format, 23
eol, 53 frame, 45
erase, 22, 45, 51 from, 79
erf, 68 fuchsia, 35
erfc, 68 functionshade, 12
error, 52, 53
gamma, 68
eval, 81
getc, 52
evenodd, 6, 38
getint, 53
exit, 24
getpair, 53
exp, 68
getreal, 53
expi, 19, 20
getstring, 53
explicit, 78
gettriple, 53
expm1, 68
gouraudshade, 11
extendcap, 37
graphic, 14
extension, 30
gray, 34, 35
green, 35
fabs, 68
guide, 31
false, 18, 54
fft, 74 hatch, 41
file, 52 heavyblue, 35
Fill, 7, 48 heavycyan, 35
fill, 9 heavygray, 35
FillDraw, 7, 47 heavygreen, 35
filldraw, 9 heavymagenta, 35
filloutside, 10 heavyred, 35
fillrule, 38 Helvetica, 39
89

hex, 23 lastcut, 30
history, 54 LATEX NFSS , 39
HookHead, 7 latitude, 20
hsv, 36 latticeshade, 10
hypot, 68 layer, 7
left, 3
I, 18
LeftSide, 14
identity, 44, 68, 75
legend, 8
if, 17
length, 18, 20, 22, 27, 33, 70
IgnoreAspect, 46
libm , 68
import, 80
lightblue, 35
inch, 1
lightcyan, 35
inch, 2
lightgray, 35
inches, 2
lightgreen, 35
include, 81
lightmagenta, 35
init, 55, 58
lightolive, 35
initialized, 70
lightred, 35
input, 52
lightyellow, 35
insert, 22, 70
line, 76
inside, 31
int, 18 linecap, 37

interior, 31 linejoin, 38

interp, 61 linetype, 37

intersect, 29 linewidth, 37
intersectionpoint, 30 list, 81
intersectionpoints, 30 locale, 23
intersections, 29 log, 68
intMax, 18 log10, 68
intMin, 18 log1p, 68
inverse, 44, 75 longdashdotted, 37
invisible, 35 longdashed, 37
longitude, 20
J, 68
Magenta, 35
keys, 70
magenta, 35
Label, 13 makepen, 42
label, 3, 12, 13 map, 72
labelmargin, 8, 12 Margin, 8
Landscape, 47 Margins, 8
90

max, 31, 45, 48, 73, 74 null, 52, 55, 56, 70


maxbound, 19, 21 nullpath, 31, 55
maxtimes, 30
O, 54
mediumblue, 35
object, 15
mediumcyan, 35
olive, 35
mediumgray, 35
opacity, 39
mediumgreen, 35
operator, 61
mediummagenta, 35
operator cast, 78
mediumred, 35
operator ecast, 79
mediumyellow, 35
operator init, 55, 58
MidArcArrow, 7
OR, 61
MidArrow, 7
orange, 35
MidPoint, 13
orientation, 47
midpoint, 29
outprefix, 46
min, 31, 45, 48, 73, 74
output, 52
minbound, 19, 21
overwrite, 15, 43
minipage, 15
mintimes, 30 pack, 15
miterjoin, 38 pair, 1, 18
miterlimit, 38 pairs, 74
mm, 2 Palatino, 39
Move, 43 paleblue, 35
MoveQuiet, 43 palecyan, 35
palegray, 35
N, 3 palegreen, 35
NE, 3 palered, 35
new, 56, 71 paleyellow, 35
NewCenturySchoolBook, 39 parent.system, 58
newframe, 45 parent.user, 58
newl, 52 path, 25
nib, 42 pattern, 40
NoAlign, 12 pen, 34
nobasealign, 38 PenMargin, 8
NoFill, 7, 48 PenMargins, 8
NoMargin, 8 picture, 46
None, 7 piecewisestraight, 27
none, 52 pink, 35
NOT, 61 point, 27, 33, 49
91

polar, 20 relpoint, 29
pop, 70 reltime, 28
Portrait, 47 remainder, 68
position, 13 rename, 54
postcontrol, 28 replace, 22
postscript, 51 restore, 51
PostScript , 39 restricted, 55
pow10, 68 reverse, 22, 29, 33, 72
precision, 53 rfind, 22
precontrol, 28 rgb, 34, 35
prepend, 45 RGB , 34
private, 55 right, 3
pt, 1 RightSide, 14
pt, 2 Rotate, 13
public, 55 rotate, 44
purple, 35 roundbox, 15, 45
push, 70 roundcap, 37
roundjoin, 38
quadraticroots, 75
royalblue, 35
quit, 1
quote, 81
safe, 54
quotient, 60
save, 51
RadialShade, 48 saveline, 54
radialshade, 10 Scale, 13
radius, 28 scale, 44, 47
read1, 76 scroll, 53
read2, 76 search, 72
read3, 76 seconds, 24
readline, 54 seek, 53
real, 18 seekeof, 53
realDigits, 18 sequence, 71
realEpsilon, 18 settings.scroll, 53
realMax, 18 Shift, 13
realMin, 18 shift, 44
realmult, 19, 21 shiftless, 45
red, 35 shipout, 46
reflect, 44 SimpleHead, 7
Relative, 13, 14 sin, 68
92

single, 53 TEX , 39
sinh, 68 texcolors, 36
size, 2, 27, 33, 46, 48 TeXHead, 7
Slant, 13 texpath, 15
slant, 44 texpreamble, 51
sleep, 25 texreset, 51
slice, 30 this, 55
solid, 37 tile, 40
solve, 74, 75 time, 23, 24
sort, 73 times, 29, 30
split, 23 TimesRoman, 39
springgreen, 35 transform, 44
sqrt, 68 transpose, 73
squarecap, 37 tridiagonal, 74
static, 82 triple, 19
stdin, 52 true, 18
stdout, 52 TrueMargin, 8
straight, 27 truepoint, 49
string, 21, 23 typedef, 25
strokepath, 31
UnFill, 7, 48
struct, 55
unfill, 12
subpath, 29
uniform, 72
substr, 22
unit, 19, 20
sum, 73
unitcircle, 3, 25
Suppress, 43
unitsize, 2, 46
SuppressQuiet, 43
unitsquare, 2
Symbol, 39
unravel, 80
system, 54
up, 3
UpsideDown, 47
tab, 52
usepackage, 51
tan, 68
usleep, 25
tanh, 68
tell, 53
void, 18
tension, 4
tension atleast, 4 while, 17
tensionSpecifier, 33 white, 35
tensorshade, 11 windingnumber, 31
tex, 51 write, 52, 58, 76
93

x, 18, 19 , 54
x , 19, 20 , 12
x11colors, 36 , 63
XDR, 53 , 19, 20
xinput, 53 , 21
XOR, 61 , 5
xoutput, 53 , 53
xpart, 19, 20 , 21
xscale, 44 , 21
, 12
Y, 68
, 44
y, 18, 19
, 44
y , 19, 20
, 44
Yellow, 35
, 44
yellow, 35
, 44
ypart, 19, 20
, 44
yscale, 44
, 44
z, 19 , 44
z , 21 , 44
ZapfChancery, 39 , 44
ZapfDingbats, 39 , 46
zerowinding, 6, 38 , 8
zpart, 21 , 25
, 25
, 19
, 14
, 4
, 9
, 1
, 17
, 44
, 18
, 20
, 1, 18
, 4 , 1
, 4 , 39
, 63 , 21
, 63 , 22
, 63 , 22
, 63 , 18
, 65 , 18, 19
, 63 , 12, 14
slice, 77 , 79
94

, 7 , 56
, 18
, 45 Coons , 11
, 19 Gouraud , 11
, 1 , 12
, 21 , 11
, 55 , 11
, 4 , 10
, 17 , 10
, 10
, 55
, 18 , 34
, 1 , 1
, 2 , 19, 21
, 61 , 3
, 17 , 8
, 4 , 34
, 17 , 38
, 7 , 39
, 18 , 39
, 69 , 38
slice, 77 , 34
null array, 70 , 38
empty array, 70 , 34
, 18 , 42
, 52 , 37
, 21 , 37
, 17 , 37
, 57 , 43
, 12 , 38
, 13 , 39
, 3, 12 , 40
, 13 , 34
, 26 , 9
, 18, 20 , 7
, 17 , 55
, 70 , 55
, 70 , 55
95

, 56 blue, 35
null array, 70 brown, 35
empty array, 70 chartreuse, 35
, 18 Cyan, 35
, 7 cyan, 35
, 59, 78 darkblue, 35
, 20 darkbrown, 35
, 20 darkcyan, 35
, 55 darkgray, 35
, 55 darkgreen, 35
, 56 darkmagenta, 35
, 4 darkolive, 35
, 59 deepblue, 35
, 3 deepcyan, 35
deepgray, 35
, 1
deepgreen, 35
, 1
deepmagenta, 35
, 59
fuchsia, 35
, 18, 19
gray, 35
, 31
green, 35
, 25
heavyblue, 35
, 8
heavycyan, 35

heavygray, 35
, 61
heavygreen, 35
, 61
heavymagenta, 35
, 60
heavyred, 35
, 61
lightblue, 35
, 61
lightcyan, 35
, 44 lightgray, 35
, 26 lightgreen, 35
, 19, 21 lightmagenta, 35
, 17 lightolive, 35
, 62 lightred, 35
static, 82 lightyellow, 35
, 26 Magenta, 35
magenta, 35
Black, 35 mediumblue, 35
black, 35 mediumcyan, 35
96

mediumgray, 35
mediumgreen, 35
mediummagenta, 35
mediumred, 35
mediumyellow, 35
olive, 35
orange, 35
paleblue, 35
palecyan, 35
palegray, 35
palegreen, 35
palered, 35
paleyellow, 35
pink, 35
purple, 35
red, 35
royalblue, 35
springgreen, 35
white, 35
Yellow, 35
yellow, 35
, 35
, 63
, 55

You might also like