You’re very welcome. It is true that there doesn’t seem to be much interest in MetaPost and METAFONT anymore, which is a shame, because they contain many brilliant ideas.
At the risk of blowing my own horn, it is also possible to draw “3D” arrows, that is, arrows using 3D coordinates that are subsequently projected using the perspective projection, using my program, GNU 3DLDF, which implements a language similar to the METAFONT language, and produces MetaPost as its output. This might be useful, if your original graphic is a 3D image.
The following toy 3DLDF program draws such a “3D” arrow within a cuboid. It should be fairly intuitive, if you’re familiar with MetaPost. Of course, the lines* and the arrowhead aren’t put into perspective, but this is standard for technical drawings (and not easy to change).
- That is, the thickness of the lines doesn’t change according to the distance from the focus. Of course, the lines themselves are in perspective.
%% ttemp.ldf
% PNG
verbatim_metapost “outputformat:=\“eps\”;outputtemplate := \”%j%c.png\“;”
& “ahlength := .5cm;”
& “outputformatoptions := \“format=rgba antialias=none\”;”;
% EPS
% verbatim_metapost “outputformat:=\“eps\”;outputtemplate := \”%j%c.eps\“;”
% & “ahlength := .5cm;”;
path frame;
frame := (-10cm, -10cm) – (10cm, -10cm) – (10cm, 10cm) – (-10cm, 10cm) – cycle;
focus f;
set f with_position (0, 0, -10) with_direction (0, 0, 10) with_distance 20;
start_x := -6;
start_y := -4;
start_z := -8;
end_x := 8;
end_y := 3;
end_z := 7;
color arrow_color;
arrow_color := red;
beginfig(0);
pickup pencircle scaled (1.5mm, 1.5mm, 1.5mm);
unfill frame;
draw frame;
%shift current_picture (0, -2);
output current_picture with_projection parallel_x_y;
clear current_picture;
cuboid c;
c := unit_cuboid scaled (12, 12, 12);
draw c;
drawarrow (start_x, start_y, start_z) – (end_x, end_y, end_z) withcolor arrow_color;
rotate current_picture (0, 30);
shift current_picture (0, 0, 20);
endfig with_focus f;
verbatim_metapost “end;”;
end;
If EPS output is produced instead of PNG, the resulting file can be included the following TeX file and the following commands will produce a PDF file:
tex ttemp
dvipdfmx ttemp
%% ttemp.tex
\nopagenumbers
\input epsf
%% * (1)
\special{papersize=210mm, 297mm} %% DIN A4 Portrait
\hsize=210mm
\vsize=297mm
\topskip=0pt
\parskip=0pt
\parindent=0pt
\baselineskip=0pt
\advance\voffset by -1in
\advance\hoffset by -1in
\topskip=0pt
\parskip=0pt
\parindent=0pt
\baselineskip=0pt
%% *** (3)
\def\epsfsize#1#2{#1}
%% *** (3)
\vbox to \vsize{\vss\hbox{\epsffile{ttemp0.eps}\hss}\vss}
\eject
\bye