Consider this test.mf
:
draw (10,20)--(10+100,20)--(10+100,20+50)--
(10+100+30,20+50)--(10+100+30,20+50-40);
showit;
end
Is there a way in metafont/metapost to draw a line of given length in a given direction without the need to specify additional variables and repeat coordinates? Something like this pseudocode for above example:
draw (10,20)--<100right>--<50up>--<30right>--<40down>;
EDIT
I came up with this but I can't make it work:
pair wire[][];
z0=(10,20);
xpart(wire1\1)=x0+100; ypart(wire1\1)=y0;
xpart(wire1\2)=xpart(wire1\1); ypart(wire1\2)=ypart(wire1\1)+50;
xpart(wire1\3)=xpart(wire1\2)+30; ypart(wire1\3)=ypart(wire1\2);
xpart(wire1\4)=xpart(wire1\3); ypart(wire1\4)=ypart(wire1\3)-40;
numeric n; n:=0;
draw z0 forever :
n:=n+1;
exitif unknown wire1[n];
-- wire1[n]
endfor;
end
\draw (10, 20) -- ++(100,0) -- ++(0, 50) -- ++(30, 0) -- (0, -40);