1 % -%-Fundamental-%- -*-Metafont-*-
2 % parmesan-macros.mf -- macros for parmesan font
4 % source file of LilyPond's pretty-but-neat music font
6 % (c) 2001--2006 Juergen Reuter <reuter@ipd.uka.de>
11 % Find point on `curve' which gives the tangent between point `p'
12 % and `curve'. To guide the search, two auxiliary points must be
13 % specified, `p_in' and `p_out'. The line between `p' and `p_in'
14 % must intersect `curve', while the line between `p' and `p_out'
17 def find_tangent (expr p, curve, p_in, p_out) =
19 save mid, t, t_good, in, out;
27 exitif abs (out - mid) <= eps;
28 t := xpart (curve intersectiontimes (p -- mid));
43 % Shift `curve' along the line given by the auxiliary points `p_in'
44 % and `p_out' until `line' is a tangent, and return the shift.
45 % If `curve' is shifted to position `p_in', it must intersect
46 % `line', while shifted to `p_out' it must not.
48 def find_tangent_shift (expr line, curve, p_in, p_out) =
50 save mid, t, t_good, in, out;
58 exitif abs (out - mid) <= eps;
59 t := xpart ((curve shifted mid) intersectiontimes line);
74 % Get subpath specified by `dir_in' and `dir_out' of `curve'
75 % which is then shifted by `offset'. Assure that result has
76 % the same orientation as `curve'.
78 def get_subpath (expr curve, dir_in, dir_out, offset) =
82 t_in := directiontime dir_in of curve;
83 t_out := directiontime dir_out of curve;
86 t_out := t_out + length curve;
89 (subpath (t_in, t_out) of curve) shifted offset
95 % This is the same as `get_subpath', except that the time values
96 % used to construct the resulting subpath are rounded to integers.
98 def get_subpath_i (expr curve, dir_in, dir_out, offset) =
102 t_in := directiontime dir_in of curve;
103 t_out := directiontime dir_out of curve;
106 t_out := t_out + length curve;
109 (subpath (floor (t_in + 0.5), floor (t_out + 0.5)) of curve)