* Documentation/user/tutorial.itely (A lead sheet): remove
[lilypond.git] / lily / lookup.cc
blob9eeb6cbdb9b73737d66ea47fa5bceea18731c348
1 /*
2 lookup.cc -- implement simple Lookup methods.
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 Jan Nieuwenhuizen <janneke@gnu.org>
10 TODO
11 Glissando
13 #include <math.h>
14 #include <ctype.h>
16 #include "warn.hh"
17 #include "dimensions.hh"
18 #include "bezier.hh"
19 #include "string-convert.hh"
20 #include "file-path.hh"
21 #include "main.hh"
22 #include "lily-guile.hh"
23 #include "molecule.hh"
24 #include "lookup.hh"
25 #include "font-metric.hh"
26 #include "interval.hh"
28 Molecule
29 Lookup::dot (Offset p, Real radius)
31 SCM at = (scm_list_n (ly_symbol2scm ("dot"),
32 gh_double2scm (p[X_AXIS]),
33 gh_double2scm (p[Y_AXIS]),
34 gh_double2scm (radius),
35 SCM_UNDEFINED));
36 Box box;
37 box.add_point (p - Offset (radius, radius));
38 box.add_point (p + Offset (radius, radius));
39 return Molecule (box, at);
42 Molecule
43 Lookup::beam (Real slope, Real width, Real thick)
45 Real height = slope * width;
46 Real min_y = (0 <? height) - thick/2;
47 Real max_y = (0 >? height) + thick/2;
51 Box b (Interval (0, width),
52 Interval (min_y, max_y));
55 SCM at = scm_list_n (ly_symbol2scm ("beam"),
56 gh_double2scm (width),
57 gh_double2scm (slope),
58 gh_double2scm (thick),
59 SCM_UNDEFINED);
60 return Molecule (b, at);
63 Molecule
64 Lookup::dashed_slur (Bezier b, Real thick, Real dash)
66 SCM l = SCM_EOL;
68 for (int i= 4; i -- ;)
70 l = gh_cons (ly_offset2scm (b.control_[i]), l);
73 SCM at = (scm_list_n (ly_symbol2scm ("dashed-slur"),
74 gh_double2scm (thick),
75 gh_double2scm (dash),
76 ly_quote_scm (l),
77 SCM_UNDEFINED));
79 Box box (Interval (0,0),Interval (0,0));
80 return Molecule (box, at);
83 Molecule
84 Lookup::line (Real th, Offset from, Offset to)
86 SCM at = scm_list_n (ly_symbol2scm ("draw-line"),
87 gh_double2scm (th),
88 gh_double2scm (from[X_AXIS]),
89 gh_double2scm (from[Y_AXIS]),
90 gh_double2scm (to[X_AXIS]),
91 gh_double2scm (to[Y_AXIS]),
92 SCM_UNDEFINED);
94 Box box;
95 box.add_point (from);
96 box.add_point (to);
98 box[X_AXIS].widen (th/2);
99 box[Y_AXIS].widen (th/2);
101 return Molecule (box, at);
104 Molecule
105 Lookup::horizontal_line (Interval w, Real th)
107 SCM at = scm_list_n (ly_symbol2scm ("horizontal-line"),
108 gh_double2scm (w[LEFT]),
109 gh_double2scm (w[RIGHT]),
110 gh_double2scm (th),
111 SCM_UNDEFINED);
114 Box box ;
115 box[X_AXIS] = w;
116 box[Y_AXIS] = Interval (-th/2,th/2);
118 return Molecule (box, at);
122 Molecule
123 Lookup::blank (Box b)
125 return Molecule (b, scm_makfrom0str (""));
128 Molecule
129 Lookup::filledbox (Box b)
131 SCM at = (scm_list_n (ly_symbol2scm ("filledbox"),
132 gh_double2scm (-b[X_AXIS][LEFT]),
133 gh_double2scm (b[X_AXIS][RIGHT]),
134 gh_double2scm (-b[Y_AXIS][DOWN]),
135 gh_double2scm (b[Y_AXIS][UP]),
136 SCM_UNDEFINED));
138 return Molecule (b,at);
142 * round filled box:
144 * __________________________________
145 * / \ ^ / \ ^
146 * | |blot | |
147 * | | |dia | | |
148 * | |meter | |
149 * |\ _ _ / v \ _ _ /| |
150 * | | |
151 * | | | Box
152 * | <------>| | extent
153 * | blot | | (Y_AXIS)
154 * | diameter| |
155 * | | |
156 * | _ _ _ _ | |
157 * |/ \ / \| |
158 * | | |
159 * | | | | |
160 * | | |
161 * x\_____/______________\_____/|_____v
162 * |(0,0) |
163 * | |
164 * | |
165 * |<-------------------------->|
166 * Box extent(X_AXIS)
168 Molecule
169 Lookup::round_filled_box (Box b, Real blotdiameter)
171 if (b.x ().length () < blotdiameter)
173 programming_error (_f ("round filled box horizontal extent smaller than blot; decreasing blot"));
174 blotdiameter = b.x ().length ();
176 if (b.y ().length () < blotdiameter)
178 programming_error (_f ("round filled box vertical extent smaller than blot; decreasing blot"));
179 blotdiameter = b.y ().length ();
182 SCM at = (scm_list_n (ly_symbol2scm ("round-filled-box"),
183 gh_double2scm (-b[X_AXIS][LEFT]),
184 gh_double2scm (b[X_AXIS][RIGHT]),
185 gh_double2scm (-b[Y_AXIS][DOWN]),
186 gh_double2scm (b[Y_AXIS][UP]),
187 gh_double2scm (blotdiameter),
188 SCM_UNDEFINED));
190 return Molecule (b,at);
196 * Create Molecule that represents a filled polygon with round edges.
198 * LIMITATIONS:
200 * (a) Only outer (convex) edges are rounded.
202 * (b) This algorithm works as expected only for polygons whose edges
203 * do not intersect. For example, the polygon ((0, 0), (q, 0), (0,
204 * q), (q, q)) has an intersection at point (q/2, q/2) and therefore
205 * will give a strange result. Even non-adjacent edges that just
206 * touch each other will in general not work as expected for non-null
207 * blotdiameter.
209 * (c) Given a polygon ((x0, y0), (x1, y1), ... , (x(n-1), y(n-1))),
210 * if there is a natural number k such that blotdiameter is greater
211 * than the maximum of { | (x(k mod n), y(k mod n)) - (x((k+1) mod n),
212 * y((k+1) mod n)) |, | (x(k mod n), y(k mod n)) - (x((k+2) mod n),
213 * y((k+2) mod n)) |, | (x((k+1) mod n), y((k+1) mod n)) - (x((k+2)
214 * mod n), y((k+2) mod n)) | }, then the outline of the rounded
215 * polygon will exceed the outline of the core polygon. In other
216 * words: Do not draw rounded polygons that have a leg smaller or
217 * thinner than blotdiameter (or set blotdiameter to a sufficiently
218 * small value -- maybe even 0.0)!
220 * NOTE: Limitations (b) and (c) arise from the fact that round edges
221 * are made by moulding sharp edges to round ones rather than adding
222 * to a core filled polygon. For details of these two different
223 * approaches, see the thread upon the ledger lines patch that started
224 * on March 25, 2002 on the devel mailing list. The below version of
225 * round_filled_polygon() sticks to the moulding model, which the
226 * majority of the list participants finally voted for. This,
227 * however, results in the above limitations and a much increased
228 * complexity of the algorithm, since it has to compute a shrinked
229 * polygon -- which is not trivial define precisely and unambigously.
230 * With the other approach, one simply could move a circle of size
231 * blotdiameter along all edges of the polygon (which is what the
232 * postscript routine in the backend effectively does, but on the
233 * shrinked polygon). --jr
235 Molecule
236 Lookup::round_filled_polygon (Array<Offset> points, Real blotdiameter)
238 /* TODO: Maybe print a warning if one of the above limitations
239 applies to the given polygon. However, this is quite complicated
240 to check. */
242 /* remove consecutive duplicate points */
243 const Real epsilon = 0.01;
244 for (int i = 0; i < points.size ();)
246 int next_i = (i + 1) % points.size ();
247 Real d = (points[i] - points[next_i]).length ();
248 if (d < epsilon)
249 points.del (next_i);
250 else
251 i++;
254 /* special cases: degenerated polygons */
255 if (points.size () == 0)
256 return Molecule ();
257 if (points.size () == 1)
258 return dot (points[0], 0.5 * blotdiameter);
259 if (points.size () == 2)
260 return line (blotdiameter, points[0], points[1]);
262 /* shrink polygon in size by 0.5 * blotdiameter */
263 Array<Offset> shrinked_points;
264 shrinked_points.set_size (points.size ());
265 bool ccw = 1; // true, if three adjacent points are counterclockwise ordered
266 for (int i = 0; i < points.size (); i++)
268 int i0 = i;
269 int i1 = (i + 1) % points.size ();
270 int i2 = (i + 2) % points.size ();
271 Offset p0 = points[i0];
272 Offset p1 = points[i1];
273 Offset p2 = points[i2];
274 Offset p10 = p0 - p1;
275 Offset p12 = p2 - p1;
276 if (p10.length () != 0.0)
277 { // recompute ccw
278 Real phi = p10.arg ();
279 // rotate (p2 - p0) by (-phi)
280 Offset q = complex_multiply (p2 - p0, complex_exp (Offset (1.0, -phi)));
282 if (q[Y_AXIS] > 0)
283 ccw = 1;
284 else if (q[Y_AXIS] < 0)
285 ccw = 0;
286 else {} // keep ccw unchanged
288 else {} // keep ccw unchanged
289 Offset p10n = (1.0 / p10.length ()) * p10; // normalize length to 1.0
290 Offset p12n = (1.0 / p12.length ()) * p12;
291 Offset p13n = 0.5 * (p10n + p12n);
292 Offset p14n = 0.5 * (p10n - p12n);
293 Offset p13;
294 Real d = p13n.length () * p14n.length (); // distance p3n to line(p1..p0)
295 if (d < epsilon)
296 // special case: p0, p1, p2 are on a single line => build
297 // vector orthogonal to (p2-p0) of length 0.5 blotdiameter
299 p13[X_AXIS] = p10[Y_AXIS];
300 p13[Y_AXIS] = -p10[X_AXIS];
301 p13 = (0.5 * blotdiameter / p13.length ()) * p13;
303 else
304 p13 = (0.5 * blotdiameter / d) * p13n;
305 shrinked_points[i1] = p1 + ((ccw) ? p13 : -p13);
308 /* build scm expression and bounding box */
309 SCM shrinked_points_scm = SCM_EOL;
310 Box box;
311 for (int i = 0; i < shrinked_points.size (); i++)
313 SCM x = gh_double2scm (shrinked_points[i][X_AXIS]);
314 SCM y = gh_double2scm (shrinked_points[i][Y_AXIS]);
315 shrinked_points_scm = gh_cons (x, gh_cons (y, shrinked_points_scm));
316 box.add_point (points[i]);
318 SCM polygon_scm = scm_list_n (ly_symbol2scm ("polygon"),
319 ly_quote_scm (shrinked_points_scm),
320 gh_double2scm (blotdiameter),
321 SCM_UNDEFINED);
323 Molecule polygon = Molecule (box, polygon_scm);
324 shrinked_points.clear ();
325 return polygon;
328 Molecule
329 Lookup::frame (Box b, Real thick)
331 Molecule m;
332 Direction d = LEFT;
333 for (Axis a = X_AXIS; a < NO_AXES; a = Axis (a + 1))
335 Axis o = Axis ((a+1)%NO_AXES);
338 Box edges;
339 edges[a] = b[a][d] + 0.5 * thick * Interval (-1, 1);
340 edges[o][DOWN] = b[o][DOWN] - thick/2;
341 edges[o][UP] = b[o][UP] + thick/2;
343 m.add_molecule (filledbox (edges));
345 while (flip (&d) != LEFT);
347 return m;
352 Make a smooth curve along the points
354 Molecule
355 Lookup::slur (Bezier curve, Real curvethick, Real linethick)
357 Real alpha = (curve.control_[3] - curve.control_[0]).arg ();
358 Bezier back = curve;
359 Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI/2)) * 0.5;
360 back.reverse ();
361 back.control_[1] += perp;
362 back.control_[2] += perp;
364 curve.control_[1] -= perp;
365 curve.control_[2] -= perp;
367 SCM scontrols[8];
369 for (int i=4; i--;)
370 scontrols[ i ] = ly_offset2scm (back.control_[i]);
371 for (int i=4 ; i--;)
372 scontrols[i+4] = ly_offset2scm (curve.control_[i]);
375 Need the weird order b.o. the way PS want its arguments
377 int indices[]= {5, 6, 7, 4, 1, 2, 3, 0};
378 SCM list = SCM_EOL;
379 for (int i= 8; i--;)
381 list = gh_cons (scontrols[indices[i]], list);
385 SCM at = (scm_list_n (ly_symbol2scm ("bezier-sandwich"),
386 ly_quote_scm (list),
387 gh_double2scm (linethick),
388 SCM_UNDEFINED));
389 Box b(curve.extent (X_AXIS),
390 curve.extent (Y_AXIS));
392 b[X_AXIS].unite (back.extent (X_AXIS));
393 b[Y_AXIS].unite (back.extent (Y_AXIS));
395 return Molecule (b, at);
399 * Bezier Sandwich:
401 * .|
402 * . |
403 * top . |
404 * . curve |
405 * . |
406 * . |
407 * . |
408 * | |
409 * | .|
410 * | .
411 * | bottom .
412 * | . curve
413 * | .
414 * | .
415 * | .
416 * | .
417 * |.
421 Molecule
422 Lookup::bezier_sandwich (Bezier top_curve, Bezier bottom_curve)
425 Need the weird order b.o. the way PS want its arguments
427 SCM list = SCM_EOL;
428 list = gh_cons (ly_offset2scm (bottom_curve.control_[3]), list);
429 list = gh_cons (ly_offset2scm (bottom_curve.control_[0]), list);
430 list = gh_cons (ly_offset2scm (bottom_curve.control_[1]), list);
431 list = gh_cons (ly_offset2scm (bottom_curve.control_[2]), list);
432 list = gh_cons (ly_offset2scm (top_curve.control_[0]), list);
433 list = gh_cons (ly_offset2scm (top_curve.control_[3]), list);
434 list = gh_cons (ly_offset2scm (top_curve.control_[2]), list);
435 list = gh_cons (ly_offset2scm (top_curve.control_[1]), list);
437 SCM horizontal_bend = scm_list_n (ly_symbol2scm ("bezier-sandwich"),
438 ly_quote_scm (list),
439 gh_double2scm (0.0),
440 SCM_UNDEFINED);
442 Interval x_extent = top_curve.extent (X_AXIS);
443 x_extent.unite (bottom_curve.extent (X_AXIS));
444 Interval y_extent = top_curve.extent (Y_AXIS);
445 y_extent.unite (bottom_curve.extent (Y_AXIS));
446 Box b (x_extent, y_extent);
448 return Molecule (b, horizontal_bend);
452 * Horizontal Slope:
454 * /| ^
455 * / | |
456 * / | | height
457 * / | |
458 * / | v
459 * | /
460 * | /
461 * (0,0) x /slope=dy/dx
462 * | /
463 * |/
465 * <----->
466 * width
468 Molecule
469 Lookup::horizontal_slope (Real width, Real slope, Real height)
471 SCM width_scm = gh_double2scm (width);
472 SCM slope_scm = gh_double2scm (slope);
473 SCM height_scm = gh_double2scm (height);
474 SCM horizontal_slope = scm_list_n (ly_symbol2scm ("beam"),
475 width_scm, slope_scm,
476 height_scm, SCM_UNDEFINED);
477 Box b (Interval (0, width),
478 Interval (-height/2, height/2 + width*slope));
479 return Molecule (b, horizontal_slope);
483 TODO: junk me.
485 Molecule
486 Lookup::accordion (SCM s, Real staff_space, Font_metric *fm)
488 Molecule m;
489 String sym = ly_scm2string (ly_car (s));
490 String reg = ly_scm2string (ly_car (ly_cdr (s)));
492 if (sym == "Discant")
494 Molecule r = fm->find_by_name ("accordion-accDiscant");
495 m.add_molecule (r);
496 if (reg.left_string (1) == "F")
498 Molecule d = fm->find_by_name ("accordion-accDot");
499 d.translate_axis (staff_space * 2.5 PT, Y_AXIS);
500 m.add_molecule (d);
501 reg = reg.right_string (reg.length ()-1);
503 int eflag = 0x00;
504 if (reg.left_string (3) == "EEE")
506 eflag = 0x07;
507 reg = reg.right_string (reg.length ()-3);
509 else if (reg.left_string (2) == "EE")
511 eflag = 0x05;
512 reg = reg.right_string (reg.length ()-2);
514 else if (reg.left_string (2) == "Eh")
516 eflag = 0x04;
517 reg = reg.right_string (reg.length ()-2);
519 else if (reg.left_string (1) == "E")
521 eflag = 0x02;
522 reg = reg.right_string (reg.length ()-1);
524 if (eflag & 0x02)
526 Molecule d = fm->find_by_name ("accordion-accDot");
527 d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
528 m.add_molecule (d);
530 if (eflag & 0x04)
532 Molecule d = fm->find_by_name ("accordion-accDot");
533 d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
534 d.translate_axis (0.8 * staff_space PT, X_AXIS);
535 m.add_molecule (d);
537 if (eflag & 0x01)
539 Molecule d = fm->find_by_name ("accordion-accDot");
540 d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
541 d.translate_axis (-0.8 * staff_space PT, X_AXIS);
542 m.add_molecule (d);
544 if (reg.left_string (2) == "SS")
546 Molecule d = fm->find_by_name ("accordion-accDot");
547 d.translate_axis (0.5 * staff_space PT, Y_AXIS);
548 d.translate_axis (0.4 * staff_space PT, X_AXIS);
549 m.add_molecule (d);
550 d.translate_axis (-0.8 * staff_space PT, X_AXIS);
551 m.add_molecule (d);
552 reg = reg.right_string (reg.length ()-2);
554 if (reg.left_string (1) == "S")
556 Molecule d = fm->find_by_name ("accordion-accDot");
557 d.translate_axis (0.5 * staff_space PT, Y_AXIS);
558 m.add_molecule (d);
559 reg = reg.right_string (reg.length ()-1);
562 else if (sym == "Freebase")
564 Molecule r = fm->find_by_name ("accordion-accFreebase");
565 m.add_molecule (r);
566 if (reg.left_string (1) == "F")
568 Molecule d = fm->find_by_name ("accordion-accDot");
569 d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
570 m.add_molecule (d);
571 reg = reg.right_string (reg.length ()-1);
573 if (reg == "E")
575 Molecule d = fm->find_by_name ("accordion-accDot");
576 d.translate_axis (staff_space * 0.5 PT, Y_AXIS);
577 m.add_molecule (d);
580 else if (sym == "Bayanbase")
582 Molecule r = fm->find_by_name ("accordion-accBayanbase");
583 m.add_molecule (r);
584 if (reg.left_string (1) == "T")
586 Molecule d = fm->find_by_name ("accordion-accDot");
587 d.translate_axis (staff_space * 2.5 PT, Y_AXIS);
588 m.add_molecule (d);
589 reg = reg.right_string (reg.length ()-1);
591 /* include 4' reed just for completeness. You don't want to use this. */
592 if (reg.left_string (1) == "F")
594 Molecule d = fm->find_by_name ("accordion-accDot");
595 d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
596 m.add_molecule (d);
597 reg = reg.right_string (reg.length ()-1);
599 if (reg.left_string (2) == "EE")
601 Molecule d = fm->find_by_name ("accordion-accDot");
602 d.translate_axis (staff_space * 0.5 PT, Y_AXIS);
603 d.translate_axis (0.4 * staff_space PT, X_AXIS);
604 m.add_molecule (d);
605 d.translate_axis (-0.8 * staff_space PT, X_AXIS);
606 m.add_molecule (d);
607 reg = reg.right_string (reg.length ()-2);
609 if (reg.left_string (1) == "E")
611 Molecule d = fm->find_by_name ("accordion-accDot");
612 d.translate_axis (staff_space * 0.5 PT, Y_AXIS);
613 m.add_molecule (d);
614 reg = reg.right_string (reg.length ()-1);
617 else if (sym == "Stdbase")
619 Molecule r = fm->find_by_name ("accordion-accStdbase");
620 m.add_molecule (r);
621 if (reg.left_string (1) == "T")
623 Molecule d = fm->find_by_name ("accordion-accDot");
624 d.translate_axis (staff_space * 3.5 PT, Y_AXIS);
625 m.add_molecule (d);
626 reg = reg.right_string (reg.length ()-1);
628 if (reg.left_string (1) == "F")
630 Molecule d = fm->find_by_name ("accordion-accDot");
631 d.translate_axis (staff_space * 2.5 PT, Y_AXIS);
632 m.add_molecule (d);
633 reg = reg.right_string (reg.length ()-1);
635 if (reg.left_string (1) == "M")
637 Molecule d = fm->find_by_name ("accordion-accDot");
638 d.translate_axis (staff_space * 2 PT, Y_AXIS);
639 d.translate_axis (staff_space PT, X_AXIS);
640 m.add_molecule (d);
641 reg = reg.right_string (reg.length ()-1);
643 if (reg.left_string (1) == "E")
645 Molecule d = fm->find_by_name ("accordion-accDot");
646 d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
647 m.add_molecule (d);
648 reg = reg.right_string (reg.length ()-1);
650 if (reg.left_string (1) == "S")
652 Molecule d = fm->find_by_name ("accordion-accDot");
653 d.translate_axis (staff_space * 0.5 PT, Y_AXIS);
654 m.add_molecule (d);
655 reg = reg.right_string (reg.length ()-1);
658 /* ugh maybe try to use regular font for S.B. and B.B and only use one font
659 for the rectangle */
660 else if (sym == "SB")
662 Molecule r = fm->find_by_name ("accordion-accSB");
663 m.add_molecule (r);
665 else if (sym == "BB")
667 Molecule r = fm->find_by_name ("accordion-accBB");
668 m.add_molecule (r);
670 else if (sym == "OldEE")
672 Molecule r = fm->find_by_name ("accordion-accOldEE");
673 m.add_molecule (r);
675 else if (sym == "OldEES")
677 Molecule r = fm->find_by_name ("accordion-accOldEES");
678 m.add_molecule (r);
680 return m;
683 Molecule
684 Lookup::repeat_slash (Real w, Real s, Real t)
686 SCM wid = gh_double2scm (w);
687 SCM sl = gh_double2scm (s);
688 SCM thick = gh_double2scm (t);
689 SCM slashnodot = scm_list_n (ly_symbol2scm ("repeat-slash"),
690 wid, sl, thick, SCM_UNDEFINED);
692 Box b (Interval (0, w + sqrt (sqr(t/s) + sqr (t))),
693 Interval (0, w * s));
695 return Molecule (b, slashnodot); // http://slashnodot.org
698 Molecule
699 Lookup::bracket (Axis a, Interval iv, Real thick, Real protude)
701 Box b;
702 Axis other = Axis((a+1)%2);
703 b[a] = iv;
704 b[other] = Interval(-1, 1) * thick * 0.5;
706 Molecule m = filledbox (b);
708 b[a] = Interval (iv[UP] - thick, iv[UP]);
709 Interval oi = Interval (-thick/2, thick/2 + fabs (protude)) ;
710 oi *= sign (protude);
711 b[other] = oi;
712 m.add_molecule (filledbox (b));
713 b[a] = Interval (iv[DOWN], iv[DOWN] +thick);
714 m.add_molecule (filledbox(b));
716 return m;
719 Molecule
720 Lookup::triangle (Interval iv, Real thick, Real protude)
722 Box b ;
723 b[X_AXIS] = iv;
724 b[Y_AXIS] = Interval (0 <? protude , 0 >? protude);
726 SCM s = scm_list_n (ly_symbol2scm ("symmetric-x-triangle"),
727 gh_double2scm (thick),
728 gh_double2scm (iv.length()),
729 gh_double2scm (protude), SCM_UNDEFINED);
731 return Molecule (b, s);
736 TODO: use rounded boxes.
738 LY_DEFINE(ly_bracket ,"ly:bracket",
739 4, 0, 0,
740 (SCM a, SCM iv, SCM t, SCM p),
741 "Make a bracket in direction @var{a}. The extent of the bracket is "
742 "given by @var{iv}. The wings protude by an amount of @var{p}, which "
743 "may be negative. The thickness is given by @var{t}.")
745 SCM_ASSERT_TYPE(ly_axis_p (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
746 SCM_ASSERT_TYPE(ly_number_pair_p (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ;
747 SCM_ASSERT_TYPE(gh_number_p (t), a, SCM_ARG3, __FUNCTION__, "number") ;
748 SCM_ASSERT_TYPE(gh_number_p (p), a, SCM_ARG4, __FUNCTION__, "number") ;
751 return Lookup::bracket ((Axis)gh_scm2int (a), ly_scm2interval (iv),
752 gh_scm2double (t),
753 gh_scm2double (p)).smobbed_copy ();
758 LY_DEFINE(ly_filled_box ,"ly:round-filled-box",
759 3, 0, 0,
760 (SCM xext, SCM yext, SCM blot),
761 "Make a filled-box of dimensions @var{xext}, @var{yext} and roundness @var{blot}.")
763 SCM_ASSERT_TYPE(ly_number_pair_p (xext), xext, SCM_ARG1, __FUNCTION__, "number pair") ;
764 SCM_ASSERT_TYPE(ly_number_pair_p (yext), yext, SCM_ARG2, __FUNCTION__, "number pair") ;
765 SCM_ASSERT_TYPE(gh_number_p (blot), blot, SCM_ARG3, __FUNCTION__, "number") ;
767 return Lookup::round_filled_box (Box (ly_scm2interval (xext), ly_scm2interval (yext)),
768 gh_scm2double (blot)).smobbed_copy ();