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 String name = String("slope");
27 Atom bs=(*symtables_)("beamslopes")->lookup (name);
32 bs.tex_ = substitute_args (bs.tex_,args);
35 bs.dim_.x() = Interval (0,width);
36 bs.dim_.y() = Interval (0,width*slope);
42 Lookup::rule_symbol (Real height, Real width) const
44 Atom bs=(*symtables_)("beamslopes")->lookup ("horizontal");
46 args.push (print_dimen (height));
47 args.push (print_dimen (width));
48 bs.tex_ = substitute_args (bs.tex_,args);
49 bs.dim_.x() = Interval (0,width);
50 bs.dim_.y() = Interval (0,height);
55 Lookup::beam (Real &slope, Real width) const
58 if (abs (slope) > 1.0)
60 WARN << "beam steeper than 1.0 (" << slope << ")\n";
64 sidx = int (rint (slope * 20.0));
67 Interval xdims = (*symtables_)("beamslopes")->lookup ("slope").dim_[X_AXIS];
68 Real min_wid = xdims[LEFT];
69 Real max_wid = xdims[RIGHT];
71 int widths = intlog2 (int (max_wid/min_wid)) + 1;
75 WARN<<"Beam too narrow. (" << print_dimen (width) <<")\n";
79 Real elemwidth = max_wid;
83 while (elemwidth > width)
88 Real overlap = elemwidth/4;
89 Real last_x = width - elemwidth;
91 Atom elem (beam_element (sidx * widths, widx, slope));
96 a.translate (Offset (x-overlap, (x-overlap)*slope));
98 x += elemwidth - overlap;
101 a.translate (Offset (last_x, (last_x) * slope));
105 ret.tex_ = m.TeX_string();
106 ret.dim_.y() = Interval (0,width*slope);
107 ret.dim_.x() = Interval (0,width);