lilypond-1.3.11
[lilypond.git] / lily / tex-beam.cc
blob002154acc452e2ae2cd33c08c2621fd66cf17219
1 /*
2 tex-beam.cc -- implement Lookup::beam
4 source file of the GNU LilyPond music typesetter
6 (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 /*
10 Code to generate beams for TeX
13 #include <math.h>
14 #include "atom.hh"
15 #include "molecule.hh"
16 #include "tex.hh"
17 #include "symtable.hh"
18 #include "dimension.hh"
19 #include "debug.hh"
20 #include "lookup.hh"
21 #include "misc.hh"
22 #include "paper-def.hh"
23 #include "string-convert.hh"
24 #include "main.hh"
27 Atom
28 Lookup::rule_symbol (Real height, Real width) const
30 Atom bs=(*symtables_p_)("param")->lookup ("rule");
31 Array<String> args;
32 args.push (print_dimen (height));
33 args.push (print_dimen (width));
34 bs.tex_ = substitute_args (bs.tex_,args);
35 bs.dim_.x() = Interval (0,width);
36 bs.dim_.y() = Interval (0,height);
37 return bs;
40 Atom
41 Lookup::beam(Real slope, Real width, Real thick) const
44 Atom a (ps_beam (slope, width, thick));
45 Real height = slope * width;
46 Real min_y = (0 <? height) - thick/2;
47 Real max_y = (0 >? height) + thick/2;
49 a.dim_[X_AXIS] = Interval(0, width);
50 a.dim_[Y_AXIS] = Interval(min_y, max_y);
51 return a;
54 Atom
55 Lookup::ps_beam (Real slope, Real width, Real thick) const
57 String ps = "\\embeddedps{\n";
58 ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
59 + " draw_beam}";
61 Atom s;
62 s.tex_ = ps;
63 return s;