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) + "}";
73 a.translate (dx/2, X_AXIS);
74 s.tex = a.TeX_string();
80 Lookup::half_slur (int dy, Real &dx, Direction dir, int xpart) const
84 return half_slur_middlepart (dx, dir);
90 WARN << "Slur half too wide." << print_dimen (orig_dx) << " shrinking (ugh)\n";
94 widx = int (rint (dx/12.0));
100 WARN << "slur too narrow " << print_dimen (orig_dx)<<"\n";
104 s.dim.x() = Interval (0,dx);
105 s.dim.y() = Interval (min (0,dy), max (0,dy));
108 String f = String ("\\hslurchar");
110 f+= direction_char (dir);
118 idx = widx * 16 + hidx;
123 f+=String ("{") + String (idx) + "}";
132 Lookup::slur (int dy , Real &dx, Direction dir) const
135 assert (abs (dir) <= 1);
138 warning ("Negative slur/tie length: " + print_dimen (dx));
141 Direction y_sign = (Direction) sign (dy);
143 bool large = abs (dy) > 8;
147 large |= dx>= 4*16 PT;
150 large |= dx>= 4*54 PT;
154 return big_slur (dy, dx, dir);
157 int widx = int (floor (dx/4.0)); // slurs better too small..
163 WARN << "slur too narrow: " << print_dimen (orig_dx) << "\n";
172 WARN<<"slur to steep: " << dy << " shrinking (ugh)\n";
176 s.dim.x() = Interval (0,dx);
177 s.dim.y() = Interval (min (0,dy), max (0,dy));
179 String f = String ("\\slurchar") + String (direction_char (y_sign));
183 idx = hidx * 16 + widx;
191 WARN << "slur too wide: " << print_dimen (dx) <<
192 " shrinking (ugh)\n";
201 f+=String ("{") + String (idx) + "}";
205 a.translate (dx/2, X_AXIS);
207 s.tex = a.TeX_string();
212 Lookup::big_slur (int dy , Real &dx, Direction dir) const
216 warning ("big_slur too small " + print_dimen (dx) + " (stretching)");
220 Real slur_extra =abs (dy) /2.0 + 2;
221 int l_dy = int (Real (dy)/2 + slur_extra*dir);
222 int r_dy = dy - l_dy;
224 Real internote_f = paper_l_->internote_f();
225 Real left_wid = dx/4.0;
226 Real right_wid = left_wid;
228 Atom l = half_slur (l_dy, left_wid, dir, -1);
229 Atom r = half_slur (r_dy, right_wid, dir, 1);
230 Real mid_wid = dx - left_wid - right_wid;
232 Atom m = half_slur (0, mid_wid, dir, 0);
237 a.translate (slur_extra * internote_f, Y_AXIS);
240 mol.translate (l_dy * internote_f, Y_AXIS);
242 s.tex = mol.TeX_string();
243 s.dim = mol.extent();