lilypond-0.1.47
[lilypond.git] / lily / bow.cc
blob7f73df520ce37746e61b144cd8179bd5a5df2a1a
1 /*
2 bow.cc -- implement Bow
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "bow.hh"
10 #include "paper-def.hh"
11 #include "molecule.hh"
12 #include "lookup.hh"
14 IMPLEMENT_IS_TYPE_B1(Bow,Directional_spanner);
16 Bow::Bow ()
18 dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = 0;
19 dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
23 Offset
24 Bow::center () const
26 Real dy = dy_f_drul_[RIGHT]-dy_f_drul_[LEFT];
28 Real w = width ().length ();
30 return Offset (w/2,dy );
33 Real
34 Bow::height_f () const
36 return 0;
39 Molecule*
40 Bow::brew_molecule_p () const
42 Molecule*output = new Molecule;
43 Real w = width ().length ();
45 Real dy_f = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT];
47 Real nw_f = paper ()->note_width ();
49 w+= (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]);
50 Real round_w = w; // slur lookup rounds the slurwidth .
52 Atom a = paper ()->lookup_l ()->slur (dy_f, round_w, height_f (), dir_);
54 Real error = w-round_w;
55 a.translate (Offset ( (dx_f_drul_[LEFT] + 0.5*nw_f)
56 + error/2,
57 dy_f_drul_[LEFT]));
58 output->add (a);
59 return output;