Asymptote FAQ - Section 5
Questions about arrows


Question 5.1. How do I draw two arrows at arbitrary positions along a path?

Assuming that at least one of the arrowheads is to be filled, you can do this:
path g=((0,0)--(5cm,0)); 
draw(g,Arrow(Relative(0.45))); 
fill(arrowhead(g,Relative(0.55)));
If both of the arrowheads are to be drawn with filltype NoFill, one will need to create a specialized version of the arrow routine in plain_arrows.asy:
void arrow(frame f, path g, pen p=currentpen, real size=0,
	   real angle=arrowangle, filltype filltype=FillDraw,
	   position position=EndPoint, bool forwards=true,
	   margin margin=NoMargin, bool center=false);

Question 5.2. How do I reverse the direction of an arrowhead?

Simply the reverse the direction of the path.
path g=((0,0)--(5cm,0)); 
draw(reverse(g),Arrow(Relative(0.55))); 

Question 5.3. How do I change the size of all arrows?

To override the arrowsize you can give every Arrow drawing attribute a real size argument. If you want to do this globally, you can override the pen-dependent arrowsize function like this:
arrowsize=new real(pen p=currentpen) {return 2mm;}; 

Question 5.4. Can I create other arrowhead styles?

Yes, you can build your own arrowheads by modifying the arrowhead routine in plain_arrows.asy:
arrowhead=new guide(path g, real position, pen p=currentpen, real size=0,
real angle=arrowangle)
{ 
... 
} 
If you submit your alternate arrowheads to the forum or the Patch Tracking System, we'll consider including them in a future release.
Next: Questions about 2D graphs.
Back: Questions about labels.
Return to contents.

Asymptote - 01 July 2007

Extracted from Asymptote Frequently Asked Questions, Copyright © 2007 .