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);
Draw the path g
on the picture pic
using pen p
for drawing, with optional drawing attributes (Label L
,
explicit label alignment align
,
arrows and bars arrow
and bar
, margins margin
,
legend, and markers marker
). Only one parameter, the path, is
required. For convenience, the arguments arrow
and bar
may be
specified in either order. The argument legend
is a Label to
use in constructing an optional legend entry.
Bars bar
are useful for indicating dimensions. The possible values of
bar
are None
, BeginBar
, EndBar
(or
equivalently Bar
), and Bars
(which draws a bar at both
ends of the path). Each of these bar specifiers (except for
None
) will accept an optional real argument that denotes the
length of the bar in PostScript
coordinates. The default
bar length is barsize(pen)
.
The possible values of arrow
are None
, Blank
(which draws no arrows or path), BeginArrow
, MidArrow
,
EndArrow
(or equivalently Arrow
),
and Arrows
(which draws an arrow at both ends of the path).
There are also arrow versions with
slightly modified default values of size
and angle
suitable for
curved arrows: BeginArcArrow
, EndArcArrow
(or equivalently
ArcArrow
), MidArcArrow
, and ArcArrows
.
For example:
draw((0,0)--(1,1),arrow=Arrows);
All of the arrow specifiers except for None
and Blank
may be given optional arguments, for example:
draw((0,0)--(1,1),arrow=Arrow( arrowhead=HookHead,size=3mm,angle=20,filltype=Draw,position=0.9));
The function Arrow
has the signature
arrowbar Arrow(arrowhead arrowhead=DefaultHead, real size=0, real angle=arrowangle, filltype filltype=null, position position=EndPoint)
Calling Arrow()
returns Arrow
, which is an arrowbar
object.
The parameters are:
arrowhead
can be one of
the predefined arrowhead styles DefaultHead
, SimpleHead
,
HookHead
, TeXHead
.
size
is the arrowhead size in PostScript
coordinates.
The default arrowhead size when drawn
with a pen p
is arrowsize(p)
.
angle
is the arrowhead angle
in degrees.
filltype
(see filltype),
MidArrow
and Arrows
) real position
(in the
sense of point(path p, real t)
) along the path where the tip of
the arrow should be placed.
Margins margin
can be used to shrink the visible portion of a path by
labelmargin(p)
to avoid overlap with other drawn objects.
Typical values of margin
are:
NoMargin
¶BeginMargin
¶EndMargin
Margins
leaves a margin at both ends of the path.
Margin(real begin, real end=begin)
specify the size of the beginning and ending margin, respectively,
in multiples of the units labelmargin(p)
used for aligning labels.
BeginPenMargin
¶EndPenMargin
PenMargins
PenMargin(real begin, real end=begin)
specify a margin in units of the pen line width, taking account of the pen line width when drawing the path or arrow.
DotMargin
an abbreviation for PenMargin(-0.5*dotfactor,0.5*dotfactor)
,
used to draw from the usual beginning point just up to the boundary of an
end dot of width dotfactor*linewidth(p)
.
BeginDotMargin
¶DotMargins
TrueMargin(real begin, real end=begin)
specify a margin directly in PostScript
units,
independent of the pen line width.
The use of arrows, bars, and margins is illustrated by the examples
Pythagoras.asy
and
sqrtx01.asy
.
The legend for a picture pic
can be fit and aligned to a frame
with the routine:
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);
Here xmargin
and ymargin
specify the surrounding x
and y margins, perline
specifies the number of entries
per line (default 1; 0 means choose this number automatically),
linelength
specifies the length of the path lines, hskip
and vskip
specify the line skip (as a multiple of the legend entry
size), maxwidth
and maxheight
specify optional upper limits
on the width and height of the resulting legend (0 means unlimited),
hstretch
and vstretch
allow the legend to stretch
horizontally or vertically, and p
specifies the pen used to draw
the bounding box. The legend frame can then be added and aligned about a
point on a picture dest
using add
or attach
(see add about).
To draw a dot, simply draw a path containing a single point.
The dot
command defined in the module plain
draws a
dot having a diameter equal to an explicit pen line width or the
default line width magnified by dotfactor
(6 by default),
using the specified filltype (see filltype) or dotfilltype
(Fill
by default):
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);
If the variable Label
is given as the Label
argument to the third routine, the format
argument will be
used to format a string based on the dot location (here defaultformat
is "$%.4g$"
).
The fourth routine draws a dot at every point of a pair array z
.
One can also draw a dot at every node of a path:
void dot(picture pic=currentpicture, Label[] L=new Label[], explicit path g, align align=RightSide, string format=defaultformat, pen p=currentpen, filltype filltype=dotfilltype);
See pathmarkers and markers
for more general
methods for marking path nodes.
To draw a fixed-sized object (in PostScript
coordinates) about
the user coordinate origin
, use the routine
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);