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"
24 Lookup::beam_element (int sidx, int widx, Real slope) const
26 char dir_char = slope >0 ? 'u' : 'd';
27 String name = dir_char + String("slope");
28 Atom bs=(*symtables_)("beamslopes")->lookup (name);
33 bs.tex_ = substitute_args (bs.tex_,args);
36 bs.dim_.x() = Interval (0,width);
37 bs.dim_.y() = Interval (0,width*slope);
41 // ugh.. hard wired tex-code.
47 WARN << "beam steeper than 0.5 (" << s << ")\n";
51 int i = int (rint (s * 20.0));
61 Lookup::rule_symbol (Real height, Real width) const
63 Atom bs=(*symtables_)("beamslopes")->lookup ("horizontal");
65 args.push (print_dimen (height));
66 args.push (print_dimen (width));
67 bs.tex_ = substitute_args (bs.tex_,args);
68 bs.dim_.x() = Interval (0,width);
69 bs.dim_.y() = Interval (0,height);
74 Lookup::beam (Real &slope, Real width) const
76 int sidx = slope_index (slope);
78 return rule_symbol (2 PT, width);
80 Interval xdims = (*symtables_)("beamslopes")->lookup ("uslope").dim_[X_AXIS];
81 Real min_wid = xdims[LEFT];
82 Real max_wid = xdims[RIGHT];
86 WARN<<"Beam too narrow. (" << print_dimen (width) <<")\n";
89 Real elemwidth = max_wid;
90 int widx = intlog2 (int (max_wid/min_wid));
94 while (elemwidth > width)
99 Real overlap = elemwidth/4;
100 Real last_x = width - elemwidth;
102 Atom elem (beam_element (sidx, widx, slope));
107 a.translate (Offset (x-overlap, (x-overlap)*slope));
109 x += elemwidth - overlap;
112 a.translate (Offset (last_x, (last_x) * slope));
116 ret.tex_ = m.TeX_string();
117 ret.dim_.y() = Interval (0,width*slope);
118 ret.dim_.x() = Interval (0,width);