]> git.donarmstrong.com Git - lilypond.git/blob - lily/bow.cc
release: 0.1.57
[lilypond.git] / lily / bow.cc
1 /*
2   bow.cc -- implement Bow
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "bow.hh"
10 #include "paper-def.hh"
11 #include "molecule.hh"
12 #include "lookup.hh"
13
14 IMPLEMENT_IS_TYPE_B1(Bow,Directional_spanner);
15
16 Bow::Bow ()
17 {
18   dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = 0;
19   dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
20 }
21
22
23 Offset
24 Bow::center () const
25 {
26   Real dy =  dy_f_drul_[RIGHT]-dy_f_drul_[LEFT];
27
28   Real w = width ().length ();
29
30   return Offset (w/2,dy );
31 }
32
33 Molecule*
34 Bow::brew_molecule_p () const
35 {
36   Molecule*output = new Molecule;
37   Real w = width ().length ();
38   
39   Real dy_f = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT];
40   
41   Real nw_f = paper ()->note_width ();
42   
43   w+= (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]);
44   Real round_w = w;             // slur lookup rounds the slurwidth .
45   
46   Atom a = paper ()->lookup_l ()->slur (dy_f, round_w, height_f (), dir_);
47
48   Real error = w-round_w;
49   a.translate (Offset ( (dx_f_drul_[LEFT] + 0.5*nw_f)
50                        + error/2,
51                        dy_f_drul_[LEFT]));
52   output->add (a);
53   return output;
54 }
55
56 Real
57 Bow::height_f () const
58 {
59   return 0;
60 }
61