2 line-interface.cc -- implement Line_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "line-interface.hh"
11 #include "molecule.hh"
13 #include "staff-symbol-referencer.hh"
19 Line_interface::make_dashed_line (Real thick, Offset from, Offset to,
20 Real dash_period, Real dash_fraction)
22 dash_fraction = (dash_fraction >? 0) <? 1.0;
23 Real on = dash_fraction * dash_period + thick;
24 Real off = dash_period - on;
26 SCM at = scm_list_n (ly_symbol2scm ("dashed-line"),
27 gh_double2scm (thick),
30 gh_double2scm (to[X_AXIS] - from[X_AXIS]),
31 gh_double2scm (to[Y_AXIS] - from[Y_AXIS]),
35 box.add_point (Offset (0,0));
36 box.add_point (to - from);
38 box[X_AXIS].widen (thick/2);
39 box[Y_AXIS].widen (thick/2);
41 Molecule m = Molecule (box, at);
46 TODO: read THICK from ME
49 Line_interface::dashed_line (Grob *me, Real thick, Offset from, Offset to)
51 SCM type = me->get_grob_property ("style");
52 if (type == ly_symbol2scm ("dotted-line")
53 || type == ly_symbol2scm ("dashed-line"))
56 robust_scm2double (me->get_grob_property ("dash-fraction"),
57 (type == ly_symbol2scm ("dotted-line")) ? 0.0 : 0.4);
59 fraction = (fraction >? 0) <? 1.0;
60 Real period = Staff_symbol_referencer::staff_space (me)
61 * robust_scm2double (me->get_grob_property ("dash-period"), 1.0);
66 return make_dashed_line (thick, from, to, period, fraction);
70 return Lookup::line (thick, from, to);
74 ADD_INTERFACE(Line_interface, "line-interface",
75 "Generic line objects. Any object using lines supports this. ",
76 "dash-period dash-fraction thickness style")