X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fline-interface.cc;h=9c16ece4106f956af5cb3a30cb4fc667065abab8;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=c12019ce0168957cb8a110f8244d9ecd451d6f0a;hpb=59a6d1a06432fc0ca88c3023c646182f389ec1b5;p=lilypond.git diff --git a/lily/line-interface.cc b/lily/line-interface.cc index c12019ce01..9c16ece410 100644 --- a/lily/line-interface.cc +++ b/lily/line-interface.cc @@ -25,8 +25,6 @@ #include "output-def.hh" #include "staff-symbol-referencer.hh" -using std::vector; - Stencil Line_interface::make_arrow (Offset begin, Offset end, Real thick, @@ -72,7 +70,7 @@ Line_interface::make_trill_line (Grob *me, } while (len + elt_len < dz.length ()); - line.rotate (dz.arg (), Offset (LEFT, CENTER)); + line.rotate (dz.angle_degrees (), Offset (LEFT, CENTER)); line.translate (from); return line; @@ -124,9 +122,9 @@ Stencil Line_interface::make_dashed_line (Real thick, Offset from, Offset to, Real dash_period, Real dash_fraction) { - dash_fraction = std::min (std::max (dash_fraction, 0.0), 1.0); - Real on = dash_fraction * dash_period + thick; - Real off = std::max (0.0, dash_period - on); + dash_fraction = min (max (dash_fraction, 0.0), 1.0); + Real on = dash_fraction * dash_period; + Real off = max (0.0, dash_period - on); SCM at = scm_list_n (ly_symbol2scm ("dashed-line"), scm_from_double (thick), @@ -220,7 +218,7 @@ Line_interface::line (Grob *me, Offset from, Offset to) ? 0.0 : robust_scm2double (me->get_property ("dash-fraction"), 0.4); - fraction = std::min (std::max (fraction, 0.0), 1.0); + fraction = min (max (fraction, 0.0), 1.0); Real period = Staff_symbol_referencer::staff_space (me) * robust_scm2double (me->get_property ("dash-period"), 1.0); @@ -228,16 +226,21 @@ Line_interface::line (Grob *me, Offset from, Offset to) return Stencil (); Real len = (to - from).length (); - - int n = (int) rint ((len - period * fraction) / period); - n = std::max (0, n); - if (n > 0) + /* + Dashed lines should begin and end with a dash. Therefore, + there will be one more dash than complete dash + whitespace + units (full periods). + */ + int full_period_count = + (int) rint ((len - period * fraction) / period); + full_period_count = max (0, full_period_count); + if (full_period_count > 0) { /* TODO: figure out something intelligent for really short sections. - */ - period = ((to - from).length () - period * fraction) / n; + */ + period = len / (fraction + full_period_count); } stencil = make_dashed_line (thick, from, to, period, fraction); }