Questions about arrows

- Q5.1. How do I draw two arrows at arbitrary positions along a path?
- Q5.2. How do I reverse the direction of an arrowhead?
- Q5.3. How do I change the size of all arrows?
- Q5.4. Can I create other arrowhead styles?

size(200); path g = (0,0)..(1,3)..(3,0); draw(g,Arrow(Relative(0.9))); add(arrow(g,invisible,FillDraw(black),Relative(0.5))); add(arrow(reverse(g),invisible,FillDraw(white,black),Relative(0.9)));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, arrowhead arrowhead=DefaultHead, path g, pen p=currentpen, real size=0, real angle=arrowangle, filltype filltype=arrowhead.defaultfilltype, position position=EndPoint, bool forwards=true, margin margin=NoMargin, bool center=false);

path g=((0,0)--(5cm,0)); draw(reverse(g),Arrow(Relative(0.55)));

DefaultHead.size=new real(pen p=currentpen) {return 2mm;};

`plain_arrows.asy`

for further examples): arrowhead DotHead; DotHead.head=new path(path g, position position=EndPoint, pen p=currentpen, real size=0, real angle=arrowangle) { if(size == 0) size=DotHead.size(p); bool relative=position.relative; real position=position.position.x; if(relative) position=reltime(g,position); path r=subpath(g,position,0); pair x=point(r,0); real t=arctime(r,size); pair y=point(r,t); return circle(0.5(x+y),0.5size); }; size(100); draw((0,0)..(1,1)..(2,0),Arrow(DotHead)); dot((2,0),red);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 - 07 April 2018

Extracted from Asymptote Frequently Asked Questions, Copyright © 2018 .