]> git.donarmstrong.com Git - lilypond.git/blob - lily/tex-beam.cc
release: 1.0.1
[lilypond.git] / lily / tex-beam.cc
1 /*
2   tex-beam.cc -- implement Lookup::beam
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 /*
10   Code to generate beams for TeX
11   */
12
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"
25
26
27 Atom
28 Lookup::rule_symbol (Real height, Real width) const
29 {
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;
38 }
39
40 Atom 
41 Lookup::beam(Real slope, Real width, Real thick) const
42 {
43   
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;
48   
49   a.dim_[X_AXIS] = Interval(0, width);
50   a.dim_[Y_AXIS] = Interval(min_y, max_y);
51   return a;
52 }
53
54 Atom
55 Lookup::ps_beam (Real slope, Real width, Real thick) const
56 {
57   String ps = "\\embeddedps{\n";
58   ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
59     + " draw_beam}";
60
61   Atom s;
62   s.tex_ = ps;
63   return s;
64 }
65