答案1
Metafun 提供了一个宏,arrowheadonpath
可以在路径上的任意位置绘制箭头time
。以下是 ConTeXt 中的一个示例,它显示了上下文中提供的三种箭头变体的箭头外观:
\startMPpage[offset=1mm]
save p; path p;
p := (1cm, 1cm) {up} .. {down} (0,0);
ahvariant := 0;
draw p ;
fill arrowheadonpath(p, 0.125);
p := p shifted (1cm,0);
ahvariant := 1;
draw p ;
fill arrowheadonpath(p, 0.125);
p := p shifted (1cm,0);
ahvariant := 2;
draw p ;
fill arrowheadonpath(p, 0.125);
\stopMPpage
这使
答案2
您也可以使用普通的 Metapost 来执行此操作。
prologues := 3;
outputtemplate := "%j%c.eps";
vardef open_arrowhead expr p =
save q,e; path q; pair e;
e = point length p of p;
q = gobble(p shifted -e cutafter makepath(pencircle scaled 2ahlength))
cuttings;
(q rotated .5ahangle & reverse q rotated -.5ahangle) shifted e
enddef;
vardef draw_open_arrow expr p =
draw p;
draw open_arrowhead p;
enddef;
beginfig(1);
path arc[];
arc0 = 100 right .. 20 down {left} .. 100 left;
arc1 = arc0 shifted 20 down rotated -10;
arc2 = reverse arc0 shifted 20 down rotated 230;
arc3 = reverse arc0 shifted 20 up reflectedabout(left, right) rotated 110;
numeric t[], u[];
(t1, t3) = arc1 intersectiontimes arc3;
(u1, u2) = arc1 intersectiontimes arc2;
(t2, u3) = arc2 intersectiontimes arc3;
% def drawarrow = draw_open_arrow enddef;
ahangle := 30;
forsuffixes $=1,2,3:
drawarrow subpath 1/2 ( 0, t$) of arc$;
drawarrow subpath 1/2 (t$, t$+u$) of arc$;
drawarrow subpath 1/2 (t$+u$, u$+2) of arc$;
draw subpath 1/2 (u$+2, 4) of arc$;
endfor
endfig;
end
编译该程序可得到mpost
以下 EPS 图:
在这里我使用了默认箭头,并将其ahangle
从默认的 45 减少到 30,这使得它们在线中间看起来更美观。
但是如果你更喜欢草图中的开放箭头,那么取消注释该行
def drawarrow = draw_open_arrow enddef;
并使箭头角度稍微大一些:
ahangle := 60;
这些变化产生了这个数字: