2 tex-slur.cc -- implement Lookup::*slur
4 source file of the GNU LilyPond music typesetter
6 (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
12 #include "molecule.hh"
15 #include "paper-def.hh"
19 direction_char (Direction y_sign
)
40 Lookup::half_slur_middlepart (Real
&dx
, Direction dir
) const
45 WARN
<<"halfslur too large" <<print_dimen (dx
)<< "shrinking (ugh)\n";
48 int widx
= int (floor (dx
/ 4.0));
53 WARN
<< "slur too narrow\n";
58 s
.dim_
.y() = Interval (min (0,0), max (0,0)); // todo
59 s
.dim_
.x() = Interval (0,dx
);
61 String f
= String ("\\hslurchar");
62 f
+= direction_char (CENTER
);
70 f
+=String ("{") + String (idx
) + "}";
72 s
.translate (dx
/2, X_AXIS
);
78 Lookup::half_slur (int dy
, Real
&dx
, Direction dir
, int xpart
) const
82 return half_slur_middlepart (dx
, dir
);
88 WARN
<< "Slur half too wide." << print_dimen (orig_dx
) << " shrinking (ugh)\n";
92 widx
= int (rint (dx
/12.0));
98 WARN
<< "slur too narrow " << print_dimen (orig_dx
)<<"\n";
102 s
.dim_
.x() = Interval (0,dx
);
103 s
.dim_
.y() = Interval (min (0,dy
), max (0,dy
));
106 String f
= String ("\\hslurchar");
108 f
+= direction_char (dir
);
116 idx
= widx
* 16 + hidx
;
121 f
+=String ("{") + String (idx
) + "}";
130 Lookup::slur (int dy
, Real
&dx
, Direction dir
) const
133 assert (abs (dir
) <= 1);
136 warning ("Negative slur/tie length: " + print_dimen (dx
));
139 Direction y_sign
= (Direction
) sign (dy
);
141 bool large
= abs (dy
) > 8;
145 large
|= dx
>= 4*16 PT
;
148 large
|= dx
>= 4*54 PT
;
152 return big_slur (dy
, dx
, dir
);
155 int widx
= int (floor (dx
/4.0)); // slurs better too small..
161 WARN
<< "slur too narrow: " << print_dimen (orig_dx
) << "\n";
170 WARN
<<"slur to steep: " << dy
<< " shrinking (ugh)\n";
174 s
.dim_
.x() = Interval (-dx
/2,dx
/2);
175 s
.dim_
.y() = Interval (min (0,dy
), max (0,dy
));
177 String f
= String ("\\slurchar") + String (direction_char (y_sign
));
181 idx
= hidx
* 16 + widx
;
189 WARN
<< "slur too wide: " << print_dimen (dx
) <<
190 " shrinking (ugh)\n";
199 f
+=String ("{") + String (idx
) + "}";
203 s
.translate (dx
/2, X_AXIS
);
208 Lookup::big_slur (int dy
, Real
&dx
, Direction dir
) const
212 warning ("big_slur too small " + print_dimen (dx
) + " (stretching)");
216 Real slur_extra
=abs (dy
) /2.0 + 2;
217 int l_dy
= int (Real (dy
)/2 + slur_extra
*dir
);
218 int r_dy
= dy
- l_dy
;
220 Real internote_f
= paper_l_
->internote_f();
221 Real left_wid
= dx
/4.0;
222 Real right_wid
= left_wid
;
224 Atom l
= half_slur (l_dy
, left_wid
, dir
, -1);
225 Atom r
= half_slur (r_dy
, right_wid
, dir
, 1);
226 Real mid_wid
= dx
- left_wid
- right_wid
;
230 Atom
a (half_slur (0, mid_wid
, dir
, 0));
231 a
.translate (slur_extra
* internote_f
, Y_AXIS
);
232 mol
.add_at_edge (X_AXIS
, RIGHT
, a
);
233 mol
.add_at_edge (X_AXIS
, RIGHT
, r
);
234 mol
.translate (l_dy
* internote_f
, Y_AXIS
);
237 s
.tex_
= mol
.TeX_string();
238 s
.dim_
= mol
.extent();