2 crescendo.cc -- implement Crescendo
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "crescendo.hh"
12 #include "font-interface.hh"
13 #include "dimensions.hh"
14 #include "paper-def.hh"
16 #include "paper-column.hh"
18 MAKE_SCHEME_CALLBACK (Crescendo
, brew_molecule
, 1);
21 Crescendo::brew_molecule (SCM smob
)
23 Score_element
*me
= unsmob_element (smob
);
24 Spanner
*span
= dynamic_cast<Spanner
*>(me
);
25 Real staff_space
= me
->paper_l ()->get_var ("staffspace");
26 Real line
= me
->paper_l ()->get_var ("stafflinethickness");
28 Real broken_left
= span
->get_broken_left_end_align ();
30 SCM s
= me
->get_elt_property("grow-direction");
37 Direction grow_dir
= to_dir (s
);
39 Real width
= span
->spanner_length ();
40 width
-= span
->get_broken_left_end_align ();
44 warning (_ ((grow_dir
< 0) ? "decrescendo too small"
45 : "crescendo too small"));
49 Drul_array
<bool> broken
;
53 Paper_column
* s
= dynamic_cast<Paper_column
*> (span
->get_bound (d
)); // UGH
54 broken
[d
] = (!s
->musical_b ());
56 while (flip (&d
) != LEFT
);
58 bool continued
= broken
[Direction (-grow_dir
)];
59 Real height
= staff_space
* gh_scm2double (me
->get_elt_property ("height"));
60 Real thick
= line
* gh_scm2double (me
->get_elt_property ("thickness"));
62 const char* type
= (grow_dir
< 0) ? "decrescendo" : "crescendo";
63 SCM hairpin
= gh_list (ly_symbol2scm (type
),
64 gh_double2scm (thick
),
65 gh_double2scm (width
),
66 gh_double2scm (height
),
67 gh_double2scm (continued
? height
/2 : 0.0),
70 Box
b (Interval (0, width
), Interval (-2*height
, 2*height
));
71 Molecule
mol (b
, hairpin
);
72 mol
.translate_axis (broken_left
, X_AXIS
);
74 return mol
.create_scheme ();