[metapost] rt does not work with drawarrow

Aditya Mahajan adityam at umich.edu
Mon Mar 12 17:57:40 CET 2007


I want to draw an arrow from a point to a line such that the tip of 
the arrow just touches the edge of the line. By default the tip of the 
arrow moves a bit into the line.

I tried rt operator with linecap = butt, which gives the desired 
behaviour for lines, but not for arrows. Any hints on how to modify 
the definition of arrowhead so that rt/left/top/down operators are 
honored, or any other way to achieve the desired effect, without 
manually adjusting the length of the line segment?

Here is my attempt:

   numeric u ; u := 1cm;
   linecap := butt ;

   pair a, b, c;
   a := origin;
   b := (2u,0) ;
   rt c = (2u,0) ;

   path line ; line := (2u,u) -- (2u,-u) ;

   draw line ;
   draw a--b withcolor red ;
   draw (a--c) shifted (0,0.5u) withcolor red ;
   currentpicture := currentpicture shifted (-4u,0) ;
   draw line ;
   drawarrow a--b withcolor red ;
   drawarrow (a--c) shifted (0,0.5u) withcolor red ;
   setbounds currentpicture to (bbox currentpicture) scaled 1.1;



More information about the metapost mailing list