From: Han-Wen Nienhuys Date: Sun, 29 Jul 2007 08:17:47 +0000 (-0700) Subject: Support correctly shortened stems on feathered beams. X-Git-Tag: release/2.11.29-1~32^2~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e888c119d6da10f12396a2916a9986201087eee0;p=lilypond.git Support correctly shortened stems on feathered beams. Clean up calc_stem_y, and incorporate feather_dir. --- diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index a40621e61b..ebda6eb256 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -179,7 +179,7 @@ Beam::quanting (SCM smob, SCM posns) if (Stem::is_normal_stem (s)) { - base_lengths.push_back (calc_stem_y (me, s, common, xl, xr, + base_lengths.push_back (calc_stem_y (me, s, common, xl, xr, CENTER, Interval (0, 0), f) / ss); } else diff --git a/lily/beam.cc b/lily/beam.cc index 183a936440..0d83aefb77 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -1132,36 +1132,40 @@ where_are_the_whole_beams (SCM beaming) in POS for stem S. This Y position is relative to S. */ Real Beam::calc_stem_y (Grob *me, Grob *stem, Grob **common, - Real xl, Real xr, + Real xl, Real xr, Direction feather_dir, Drul_array pos, bool french) { Real beam_translation = get_beam_translation (me); + Direction stem_dir = get_grob_direction (stem); - Real r = stem->relative_coordinate (common[X_AXIS], X_AXIS) - xl; - Real dy = pos[RIGHT] - pos[LEFT]; Real dx = xr - xl; - Real stem_y_beam0 = (dy && dx - ? r / dx - * dy - : 0) + pos[LEFT]; + Real relx = dx ? (stem->relative_coordinate (common[X_AXIS], X_AXIS) - xl)/dx : 0; + Real xdir = 2*relx-1; + + Real stem_y = linear_combination(pos, xdir); - Direction my_dir = get_grob_direction (stem); SCM beaming = stem->get_property ("beaming"); - Real stem_y = stem_y_beam0; - if (french) - { - Slice bm = where_are_the_whole_beams (beaming); - if (!bm.is_empty ()) - stem_y += beam_translation * bm[-my_dir]; - } - else - { - Slice bm = Stem::beam_multiplicity (stem); - if (!bm.is_empty ()) - stem_y += bm[my_dir] * beam_translation; - } + Slice beam_slice (french + ? where_are_the_whole_beams (beaming) + : Stem::beam_multiplicity (stem)); + + Interval beam_multiplicity(beam_slice[LEFT], + beam_slice[RIGHT]); + /* + feather dir = 1 , relx 0->1 : factor 0 -> 1 + feather dir = 0 , relx 0->1 : factor 1 -> 1 + feather dir = -1, relx 0->1 : factor 1 -> 0 + */ + Real feather_factor = 1; + if (feather_dir > 0) + feather_factor = relx; + else if (feather_dir < 0) + feather_factor = 1 - relx; + + stem_y += feather_factor * beam_translation + * beam_multiplicity[Direction(((french) ? DOWN : UP)*stem_dir)]; Real id = me->relative_coordinate (common[Y_AXIS], Y_AXIS) - stem->relative_coordinate (common[Y_AXIS], Y_AXIS); @@ -1209,6 +1213,7 @@ Beam::set_stem_lengths (SCM smob) Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; Real xr = lvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; + Direction feather_dir = to_dir (me->get_property ("grow-direction")); for (vsize i = 0; i < stems.size (); i++) { @@ -1216,7 +1221,7 @@ Beam::set_stem_lengths (SCM smob) bool french = to_boolean (s->get_property ("french-beaming")); Real stem_y = calc_stem_y (me, s, common, - xl, xr, + xl, xr, feather_dir, pos, french && s != lvs && s!= fvs); /* diff --git a/lily/include/beam.hh b/lily/include/beam.hh index dee61b467b..fc3a722cac 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -122,7 +122,7 @@ private: static void consider_auto_knees (Grob *); static void set_stem_shorten (Grob *); static Real calc_stem_y (Grob *, Grob *s, Grob **c, - Real, Real, + Real, Real, Direction, Drul_array pos, bool french); static int forced_stem_count (Grob *); };