2 tex-beam.cc -- implement Lookup::{beam_element, beam, rule_symbol}
4 source file of the GNU LilyPond music typesetter
6 (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 Code to generate beams for TeX
15 #include "molecule.hh"
17 #include "symtable.hh"
23 Lookup::beam_element (int sidx, int widx, Real slope) const
25 Atom bs=(*symtables_)("beamslopes")->lookup ("slope");
30 bs.tex_ = substitute_args (bs.tex_,args);
33 bs.dim_.x() = Interval (0,width);
34 bs.dim_.y() = Interval (0,width*slope);
38 // ugh.. hard wired tex-code.
44 WARN << "beam steeper than 0.5 (" << s << ")\n";
48 int i = int (rint (s * 20.0));
58 Lookup::rule_symbol (Real height, Real width) const
60 Atom bs=(*symtables_)("beamslopes")->lookup ("horizontal");
62 args.push (print_dimen (height));
63 args.push (print_dimen (width));
64 bs.tex_ = substitute_args (bs.tex_,args);
65 bs.dim_.x() = Interval (0,width);
66 bs.dim_.y() = Interval (0,height);
71 Lookup::beam (Real &slope, Real width) const
73 int sidx = slope_index (slope);
75 return rule_symbol (2 PT, width);
78 WARN<<"Beam too narrow. (" << print_dimen (width) <<")\n";
81 Real elemwidth = 64 PT;
86 while (elemwidth > width)
91 Real overlap = elemwidth/4;
92 Real last_x = width - elemwidth;
94 Atom elem (beam_element (sidx, widx, slope));
100 a.translate (Offset (x-overlap, (x-overlap)*slope));
102 x += elemwidth - overlap;
105 a.translate (Offset (last_x, (last_x) * slope));
109 ret.tex_ = m.TeX_string();
110 ret.dim_.y() = Interval (0,width*slope);
111 ret.dim_.x() = Interval (0,width);