3.3 Figure size

In Asymptote, coordinates like (0,0) and (100,100), called pairs, are expressed in PostScript "big points" (1 bp = 1/72 inch) and the default line width is 0.5bp. However, it is often inconvenient to work directly in PostScript coordinates. The next example produces identical output to the previous example, by scaling the line (0,0)--(1,1) to fit a rectangle of width 100.5 bp and height 100.5 bp (the extra 0.5bp accounts for the line width):

size(100.5,100.5);
draw((0,0)--(1,1));

./diagonal

One can also specify the size in pt (1 pt = 1/72.27 inch), cm, mm, or inches. Two nonzero size arguments (or a single size argument) restrict the size in both directions, preserving the aspect ratio. If 0 is given as a size argument, no restriction is made in that direction; the overall scaling will be determined by the other direction (see size):

size(0,100.5);
draw((0,0)--(2,1),Arrow);

./bigdiagonal

To connect several points and create a cyclic path, use the cycle keyword:

size(3cm);
draw((0,0)--(1,0)--(1,1)--(0,1)--cycle);

./square

For convenience, the path (0,0)--(1,0)--(1,1)--(0,1)--cycle may be replaced with the predefined variable unitsquare, or equivalently, box((0,0),(1,1)).

To make the user coordinates represent multiples of exactly 1cm:

unitsize(1cm);
draw(unitsquare);