+
+
+
+
+Molecule
+Tie::do_brew_molecule () const
+{
+ Real thick = paper_l ()->get_var ("tie_thickness");
+ Bezier one = get_curve ();
+
+ Molecule a;
+ SCM d = get_elt_property ("dashed");
+ if (gh_number_p (d))
+ a = lookup_l ()->dashed_slur (one, thick, gh_scm2int (d));
+ else
+ a = lookup_l ()->slur (one, directional_element (this).get () * thick, thick);
+
+ return a;
+}
+
+
+
+Bezier
+Tie::get_curve () const
+{
+ Direction d (directional_element (this).get ());
+ Bezier_bow b (get_encompass_offset_arr (), d);
+
+ Real staff_space = staff_symbol_referencer (this).staff_space ();
+ Real h_inf = paper_l ()->get_var ("tie_height_limit_factor") * staff_space;
+ Real r_0 = paper_l ()->get_var ("tie_ratio");
+
+ b.set_default_bezier (h_inf, r_0);
+ Bezier c = b.get_bezier ();
+
+ /* should do this for slurs as well. */
+ Array<Real> horizontal (c.solve_derivative (Offset (1,0)));
+
+ if (horizontal.size ())
+ {
+ /*
+ ugh. Doesnt work for non-horizontal curves.
+ */
+ Real y = c.curve_point (horizontal[0])[Y_AXIS];
+
+ Real ry = rint (y/staff_space) * staff_space;
+ Real diff = ry - y;
+ Real newy = y;
+ if (fabs (y) <= 2.0
+ && fabs (diff) < paper_l ()->get_var ("tie_staffline_clearance"))
+ {
+ newy = ry - 0.5 * staff_space * sign (diff) ;
+ }
+
+ Real y0 = c.control_ [0][Y_AXIS];
+ c.control_[2][Y_AXIS] =
+ c.control_[1][Y_AXIS] =
+ (c.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0;
+ }
+ else
+ programming_error ("Tie is nowhere horizontal");
+ return c;
+}
+
+Array<Offset>
+Tie::get_encompass_offset_arr () const
+{
+ Array<Offset> offset_arr;
+ offset_arr.push (Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT]));
+ offset_arr.push (Offset (spanner_length () + dx_f_drul_[RIGHT],
+ dy_f_drul_[RIGHT]));
+
+ return offset_arr;
+}
+
+