[metapost] rt does not work with drawarrow

Aditya Mahajan adityam at umich.edu
Tue Mar 13 01:03:19 CET 2007


On Mon, 12 Mar 2007, Wolfgang Schuster wrote:

> On Mon, 12 Mar 2007 11:57:40 -0500 (EST)
> Aditya Mahajan <adityam at umich.edu> wrote:
>
>> Hi,
>>
>> 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:
>>
>> beginfig(1)
>>    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 ;
>                  ^^^
>                 "lft c" instead "c" works

Ah! Thank you.

>>    setbounds currentpicture to (bbox currentpicture) scaled 1.1;
>> endfig;
>>
>> end;

Aditya


More information about the metapost mailing list