Hi! Attached is a revision of the patch that I sent on last December 31st, regarding ledger lines. It was rejected due to blotdiameter problems. I tried to solve them as far as possible, revealing some oddities that are still in lily. Hence, I hope this patch satisfies your quality constraints, even if it still contains some issues, which, however, reflect more general issues of lily that I can not fix in a single patch -- this patch is already quite big as for a few relatively simple goals!
The simple goals of this patch are: * Junk multiple implementations of ledger line creation in note_head, custos, and porrectus. This is important since there soon will be some more applications of ledger lines to come (e.g. ambitus engraver). * Make thickness of ledgerlines adjustable. This is essential for mensural notation. * Fix some bugs in the current ledger_line implementation, most notably that of the horizontal extent of ledger lines which equals at least the extent of the metafont ledger_line character, and which grows(!) if the desired extent shrinks below this limit. When I sent the first revision of this patch, it was rejected since the resulting ledger lines had sharp edges, although the draw_box routine in music-drawing-routines.ps seemed to regard blotdiameter. In the meantime, draw_box seems to consider blotdiameter (at least with the environment of my machine). Though a faced a couple of new problems that I would like to discuss. First of all, I think the current model of blotdiameter may lead to weird effects, not to say that it is mathmatically seen ambigous. Let me explain this on the example of draw_box. draw_box draws a box with round edges as follows: __________________________ ______ / \ ^ / \ ^ | |blot | | | | |dia | | | | |meter | | |\ _ _ / v \ _ _ /| | | | | | | | Box | <------>| | extent | blot | | (Y_AXIS) | diameter| | | | | | _ _ _ _ | | |/ \ / \| | | | | | | | | | |(0,0) | v x\_____/______________\_____/ ______ | | | | | | |<-------------------------->| Box extent(X_AXIS) This works well, as long as the extent (either X_AXIS or Y_AXIS) is greater than or equal to blotdiameter. However, if below blotdiameter, you get, in the best case weird effects, or in the worst case, ambigous behaviour. In my opinion, if below blotdiameter, draw_box should create a blot, i.e. a dot of size blotdiameter. To implement this correctly, draw_box probably should bound the extent via doing something like x_extent:=max(blotdiameter,x_extent), and the same for y extent; otherwise you may internally end up operating with negative values for width or height. To circumvent this situation, I would like to suggest a different model for "blotting" an existing shape: given an arbitrary shape, just move a pencircle of size blotdiameter around the outline of this shape to create a blotted shape. In the case of draw_box, this leads to the following model: __________________________ / \ ^ / \ | |blot | | + | |dia | +---|------ | |meter | ^ |\ _ _ / v \ _ _ /| | | | | | | | Box | <------>| | extent | blot | | (Y_AXIS) | diameter| | | | | | _ _ _ _ | | |/ \ / \| | | (0,0) | v | x | | +---|------ | | | | \__|__/______________\__|__/ | | | | | | |<------------------>| Box extent(X_AXIS) Note, that "blotting" slightly increases the dimensions of an existing shape by half the diameter of the blot. However, you solve the above problems of an extent smaller than blotdiameter in a natural way. If the extent is set to 0, with this model, you really get a single blot (i.e. a circle with diameter blotdiameter) as result. In my attached patch, I have included an implementation for the above box model (at least for ps; I could not find out how to easily draw a circle in pdf; any volunteers appreciated!); see Lookup::roundfilledbox (). This model is general enough to apply to any shape with a steady outline and has some more advantageous properties regarding backwards compatibility to work done earlier in lilypond. As you correctly presumed, the porrectus shape is broken due to the recently introduced blotting on beams and bezier curves. For example, have a look at composing complex shapes from beams. a) Shape composed from beams without blotting: |\ | \ | \ | \ | \ | \ \ \ \ | |\ | | \ | | \ | | \| | \ \ | \ | \ | \| b) The same shape composed from beams with blotting similar to current draw_box implementation: _ / \ | \ | \ | \ \ \ \ | \ | \ | / \_/ | \ | \ \ | \ | \_/ b) Once again the same shape composed from beams with blotting as above suggested: _ / \ | \ | \ | \ | \ | \ | \ \ \ | | | | | | | | \ | \ | \ | \ | \_/ In c), the two shapes overlap by an amount such that inner edges as in b) do not arise. Actually, from having a look at mensural porrectus in ancient-font.ly, the current implementation of beam seems to be a mixture of b) and c), which is even worse... By the way, I think, blotdiameter should be passed as parameter to general-purpose functions like filledbox, since different notation styles may prefer different values for blotdiameter. The fact that in the metafont code, pencircles of different sizes are used, stresses this need. With the current implementation, setting blotdiameter in the paper block has no effect on Lookup::filledbox; my implementation of Lookup::roundfilledbox however considers blotdiameter; and this effect can also be seen on ledger_lines if Lookup::roundfilledbox is used in Note-head::brew_ledger_lines. By another way, do I really need a Grob *me, to do a thing like me->paper_l ()->get_var ("...")? I think, these variables are global, and hence there should be a possibilty of accessing them without having a Grob at hand (I really do not like to pass a Grob into a function of class Lookup). Or am I missing here something? Ah, and yes, it seems the blotdiameter on bezier curves and filledbox (when called by roundfilledbox on the ps level in ps.scm) is too big by an estimated factor of 2. Maybe radius and diameter have been confused somewhere? For compensation of this error, the call to Lookup::roundfilledbox in Note-head::brew_ledger_lines currently uses a blotdiameter multiplied by a factor of 2.0. This constant should be removed as soon as this error is fixed. To switch between filledbox and roundfilledbox when creating ledger lines, just comment in/out the proper call in Note-head::brew_ledger_lines. porrectus.cc: > /* > > TODO: > > ugr. why not called direction? > > */ > SCM stem_direction_scm = me->get_grob_property ("direction"); Because it's really only the direction of the stem (or rather "cauda"), not the direction of the whole grob. But this code will have to be revised in a few weeks, anyway. Greetings, Juergen
diff -Naur lilypond-1.5.47/ChangeLog lilypond-1.5.47.NEW/ChangeLog --- lilypond-1.5.47/ChangeLog Sun Mar 24 22:07:04 2002 +++ lilypond-1.5.47.NEW/ChangeLog Mon Mar 25 23:37:43 2002 @@ -1,3 +1,20 @@ +2002-03-25 Juergen Reuter <[EMAIL PROTECTED]> + + * Code clean-up: Junk multiple implementations of ledger line + creation in note_head, custos, and porrectus. This is important + since there soon will be some more applications of ledger lines to + come (e.g. ambitus engraver). + + * Make thickness of ledger lines adjustable. This is essential + for mensural notation. + + * Fix some bugs in the current ledger_line implementation, most + notably that of the horizontal extent of ledger lines which equals + at least the extent of the metafont ledger_line character, and + which grows(!) if the desired extent shrinks below this limit. + + * roundfilledbox: variable blotdiameter + 2002-03-24 Han-Wen <[EMAIL PROTECTED]> * VERSION: 1.5.47 released diff -Naur lilypond-1.5.47/lily/custos.cc lilypond-1.5.47.NEW/lily/custos.cc --- lilypond-1.5.47/lily/custos.cc Sun Mar 24 21:46:53 2002 +++ lilypond-1.5.47.NEW/lily/custos.cc Mon Mar 25 23:20:18 2002 @@ -30,111 +30,6 @@ #include "font-interface.hh" #include "math.h" // rint -/* - This function is a patched and hopefully much more understandable - rewrite of Note_head::ledger_line (). It still has some - bugs/limitations: - * - (1) The term thick/2 probably should be thick*2 (probably a bug, - see the code below). - * - (2) The minimal width of the resulting ledger line equals the width - of the noteheads-ledgerending symbol (a limitation): - * - (---- left ledger ending - ----) right ledger ending - (---) resulting ledger line (just ok) - * - If x_extent ("xwid" in Note_head) is less than the width of the - ledger ending, the width of the total ledger line is even *greater* - than the width of a ledger ending (I would call this a bug). In - the below code, the condition "if (x_extent.length () > - slice_x_extent.length ())" avoids outputting the left ending in such - cases (rather a silly workaround, but better than nothing). - * - (---- left ledger ending - ----) right ledger ending - (-) desired ledger line - ------- resulting ledger line (too long) - ----) resulting ledger line with additional "if" (still too long) - * - The algorithm works properly only for a desired ledger line width - greater than the width of the ledger ending: - * - (---- left ledger ending - ----) right ledger ending - (------) desired ledger line - (------) resulting ledger line (ok) - * - * (3) The thickness of the ledger line is fixed (limitation). - */ -Molecule -Custos::create_ledger_line (Interval x_extent, Grob *me) -{ - Molecule line; - Molecule slice = Font_interface::get_default_font (me)->find_by_name ("noteheads-ledgerending"); - Interval slice_x_extent = slice.extent (X_AXIS); - Interval slice_y_extent = slice.extent (Y_AXIS); - - // Create left ending of ledger line. - Molecule left_ending = slice; - left_ending.translate_axis (x_extent[LEFT] - slice_x_extent[LEFT], X_AXIS); - if (x_extent.length () > slice_x_extent.length ()) - line.add_molecule (left_ending); - - // Create right ending of ledger line. - Molecule right_ending = slice; - right_ending.translate_axis (x_extent[RIGHT] - slice_x_extent[RIGHT], - X_AXIS); - line.add_molecule (right_ending); - - // Fill out space between left and right ending of ledger line by - // lining up a series of slices in a row between them. - Molecule fill_out_slice = left_ending; - Real thick = slice_y_extent.length (); - Real delta_x = slice_x_extent.length () - thick; - Real xpos = x_extent [LEFT] + 2*delta_x + thick/2; // TODO: check: thick*2? - while (xpos <= x_extent[RIGHT]) - { - fill_out_slice.translate_axis (delta_x, X_AXIS); - line.add_molecule (fill_out_slice); - xpos += delta_x; - } - - return line; -} - -void -Custos::add_streepjes (Grob* me, - int pos, - int interspaces, - Molecule* custos_p_) -{ - // TODO: This is (almost) duplicated code (see - // Note_head::brew_molecule). Junk me. - Real inter_f = Staff_symbol_referencer::staff_space (me)/2; - int streepjes_i = abs (pos) < interspaces - ? 0 - : (abs (pos) - interspaces) /2; - if (streepjes_i) - { - Direction dir = (Direction)sign (pos); - Molecule ledger_line (create_ledger_line (custos_p_->extent (X_AXIS), - me)); - ledger_line.set_empty (true); - Real offs = (Staff_symbol_referencer::on_staffline (me)) - ? 0.0 - : -dir * inter_f; - for (int i = 0; i < streepjes_i; i++) - { - Molecule streep (ledger_line); - streep.translate_axis (-dir * inter_f * i * 2 + offs, - Y_AXIS); - custos_p_->add_molecule (streep); - } - } -} - MAKE_SCHEME_CALLBACK (Custos,brew_molecule,1); SCM Custos::brew_molecule (SCM smob) @@ -147,9 +42,9 @@ String style = ly_scm2string (scm_symbol_to_string (scm_style)); /* - DOCME: - - Why would we want it differently? What's the meaning of adjust ? + * Shall we use a common custos font character regardless if on + * staffline or not, or shall we use individual font characters + * for both cases? */ bool adjust = to_boolean (me->get_grob_property ("adjust-if-on-staffline")); @@ -199,8 +94,17 @@ } else { - add_streepjes (me, (int)pos, sz, &molecule); - return molecule.smobbed_copy (); + // add ledger lines + int pos = (int)rint (Staff_symbol_referencer::position_f (me)); + int interspaces = Staff_symbol_referencer::line_count (me)-1; + if (abs (pos) - interspaces > 1) + { + Molecule ledger_lines = + Note_head::brew_ledger_lines (me, pos, interspaces, + molecule.extent (X_AXIS), true); + molecule.add_molecule (ledger_lines); + } + return molecule.smobbed_copy (); } } else @@ -212,7 +116,6 @@ { return m && m->has_interface (ly_symbol2scm ("custos-interface")); } - ADD_INTERFACE (Custos, "custos-interface", "A custos is a staff context symbol that appears at the end of a diff -Naur lilypond-1.5.47/lily/include/lookup.hh lilypond-1.5.47.NEW/lily/include/lookup.hh --- lilypond-1.5.47/lily/include/lookup.hh Fri Mar 22 10:45:58 2002 +++ lilypond-1.5.47.NEW/lily/include/lookup.hh Mon Mar 25 23:40:09 2002 @@ -21,14 +21,15 @@ static Molecule bracket (Axis a, Interval iv, Direction d, Real thick, Real protude); static Molecule accordion (SCM arg, Real interline_f, Font_metric*fm); static Molecule frame (Box b, Real thick); - static Molecule slur (Bezier controls, Real cthick, Real thick) ; - static Molecule bezier_sandwich (Bezier, Bezier); - static Molecule horizontal_slope (Real, Real, Real); - static Molecule beam (Real, Real, Real) ; - static Molecule dashed_slur (Bezier, Real thick, Real dash) ; - static Molecule blank (Box b) ; - static Molecule filledbox (Box b) ; - static Molecule repeat_slash( Real w, Real slope, Real th); + static Molecule slur (Bezier controls, Real cthick, Real thick); + static Molecule bezier_sandwich (Bezier top_curve, Bezier bottom_curve); + static Molecule horizontal_slope (Real width, Real slope, Real height); + static Molecule beam (Real slope, Real width, Real thick); + static Molecule dashed_slur (Bezier, Real thick, Real dash); + static Molecule blank (Box b); + static Molecule filledbox (Box b); + static Molecule roundfilledbox (Box b, Real blotdiameter); + static Molecule repeat_slash (Real w, Real slope, Real th); }; #endif // LOOKUP_HH diff -Naur lilypond-1.5.47/lily/include/note-head.hh lilypond-1.5.47.NEW/lily/include/note-head.hh --- lilypond-1.5.47/lily/include/note-head.hh Sun Mar 17 20:54:34 2002 +++ lilypond-1.5.47.NEW/lily/include/note-head.hh Mon Mar 25 23:40:14 2002 @@ -21,9 +21,9 @@ { public: DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM )); - static Interval head_extent (Grob*,Axis); - static Molecule ledger_lines (Grob*, bool, int,Direction,Interval); - static Molecule ledger_line ( Grob*, Interval); + static Interval head_extent (Grob*, Axis); + static Molecule brew_ledger_lines (Grob *me, int pos, int interspaces, + Interval x_extent, bool take_space); DECLARE_SCHEME_CALLBACK (brew_ez_molecule, (SCM )); static bool has_interface (Grob*); static Real stem_attachment_coordinate (Grob *, Axis a); diff -Naur lilypond-1.5.47/lily/lookup.cc lilypond-1.5.47.NEW/lily/lookup.cc --- lilypond-1.5.47/lily/lookup.cc Sun Mar 24 21:46:54 2002 +++ lilypond-1.5.47.NEW/lily/lookup.cc Mon Mar 25 23:40:18 2002 @@ -45,7 +45,6 @@ return Molecule (b, at); } - Molecule Lookup::dashed_slur (Bezier b, Real thick, Real dash) { @@ -72,7 +71,6 @@ return Molecule (b, SCM_EOL); } - Molecule Lookup::filledbox (Box b) { @@ -86,6 +84,46 @@ return Molecule (b,at); } +/* + * round filled box: + * + * __________________________ + * / \ ^ / \ + * | |blot | + * | + | |dia | +---|------ + * | |meter | ^ + * |\ _ _ / v \ _ _ /| | + * | | | + * | | | Box + * | <------>| | extent + * | blot | | (Y_AXIS) + * | diameter| | + * | | | + * | _ _ _ _ | | + * |/ \ / \| | + * | (0,0) | v + * | x | | +---|------ + * | | | | + * \__|__/______________\__|__/ + * | | + * | | + * | | + * |<------------------>| + * Box extent(X_AXIS) + */ +Molecule +Lookup::roundfilledbox (Box b, Real blotdiameter) +{ + SCM at = (scm_list_n (ly_symbol2scm ("roundfilledbox"), + gh_double2scm (-b[X_AXIS][LEFT]), + gh_double2scm (b[X_AXIS][RIGHT]), + gh_double2scm (-b[Y_AXIS][DOWN]), + gh_double2scm (b[Y_AXIS][UP]), + gh_double2scm (blotdiameter), + SCM_UNDEFINED)); + + return Molecule (b,at); +} Molecule Lookup::frame (Box b, Real thick) @@ -112,7 +150,6 @@ } - /* Make a smooth curve along the points */ @@ -459,8 +496,6 @@ return Molecule (b, slashnodot); // http://slashnodot.org } - - Molecule Lookup::bracket (Axis a, Interval iv, Direction d, Real thick, Real protude) diff -Naur lilypond-1.5.47/lily/note-head.cc lilypond-1.5.47.NEW/lily/note-head.cc --- lilypond-1.5.47/lily/note-head.cc Sun Mar 24 21:46:54 2002 +++ lilypond-1.5.47.NEW/lily/note-head.cc Mon Mar 25 23:40:27 2002 @@ -16,6 +16,9 @@ #include "molecule.hh" #include "musical-request.hh" #include "rhythmic-head.hh" +#include "staff-symbol-referencer.hh" +#include "lookup.hh" +#include "paper-def.hh" /* Note_head contains the code for printing note heads. @@ -54,87 +57,58 @@ */ -#include "staff-symbol-referencer.hh" - -/* - build a ledger line for small pieces. - */ -Molecule -Note_head::ledger_line (Grob *me, Interval xwid) -{ - Drul_array<Molecule> endings; - endings[LEFT] = Font_interface::get_default_font (me)->find_by_name ("noteheads-ledgerending"); - Molecule *e = &endings[LEFT]; - endings[RIGHT] = *e; - - Real thick = e->extent (Y_AXIS).length (); - Real len = e->extent (X_AXIS).length () - thick; - - Molecule total; - Direction d = LEFT; - do { - endings[d].translate_axis (xwid[d] - endings[d].extent (X_AXIS)[d], X_AXIS); - total.add_molecule (endings[d]); - } while ((flip (&d)) != LEFT); - - Real xpos = xwid [LEFT] + len; - - while (xpos + len + thick /2 <= xwid[RIGHT]) - { - e->translate_axis (len, X_AXIS); - total.add_molecule (*e); - xpos += len; - } - - return total; -} - - Molecule -Note_head::ledger_lines (Grob*me, - bool take_space, - int count, Direction dir, Interval idw) +Note_head::brew_ledger_lines (Grob *me, + int pos, + int interspaces, + Interval x_extent, + bool take_space) { Real inter_f = Staff_symbol_referencer::staff_space (me)/2; + int lines_i = abs (pos) < interspaces + ? 0 + : (abs (pos) - interspaces) / 2; + Molecule molecule = Molecule(); - /* - idw ? - - (who's that ? :-) - - - --hwn - */ - Molecule ledger (ledger_line (me, idw)); - - if (!take_space) - ledger.set_empty (true); - - Real offs = (Staff_symbol_referencer::on_staffline (me)) - ? 0.0 - : -dir * inter_f; - - Molecule legs; - for (int i=0; i < count; i++) + if (lines_i) { - Molecule s (ledger); - s.translate_axis (-dir * inter_f * i*2 + offs, - Y_AXIS); - legs.add_molecule (s); + Real ledgerlinethickness = + (me->paper_l ()->get_var ("ledgerlinethickness")); + Real blotdiameter = + (me->paper_l ()->get_var ("blotdiameter")); + Interval y_extent = + Interval (-0.5*ledgerlinethickness, +0.5*ledgerlinethickness); + Box ledger_line (x_extent, y_extent); + + // FIXME: Currently need blotdiameter factor 2.0 to compensate + // for error somewhere else. (Maybe draw_box confuses radius + // and diameter?) + // Molecule proto_ledger_line = + // Lookup::roundfilledbox (ledger_line, blotdiameter*2.0); + Molecule proto_ledger_line = // if you like it the old way + Lookup::filledbox (ledger_line); + + if (!take_space) + proto_ledger_line.set_empty (true); + + Direction dir = (Direction)sign (pos); + Real offs = (Staff_symbol_referencer::on_staffline (me, pos)) + ? 0.0 + : -dir * inter_f; + for (int i = 0; i < lines_i; i++) + { + Molecule ledger_line (proto_ledger_line); + ledger_line.translate_axis (-dir * inter_f * i * 2 + offs, Y_AXIS); + molecule.add_molecule (ledger_line); + } } - return legs; + return molecule; } Molecule internal_brew_molecule (Grob *me, bool ledger_take_space) { - int sz = Staff_symbol_referencer::line_count (me)-1; - int p = (int) rint (Staff_symbol_referencer::position_f (me)); - int streepjes_i = abs (p) < sz - ? 0 - : (abs (p) - sz) /2; - SCM style = me->get_grob_property ("style"); if (!gh_symbol_p (style)) { @@ -153,9 +127,10 @@ String name = "noteheads-" + ly_scm2string (scm_primitive_eval (exp)); Molecule out = Font_interface::get_default_font (me)->find_by_name (name); - if (streepjes_i) + int interspaces = Staff_symbol_referencer::line_count (me)-1; + int pos = (int)rint (Staff_symbol_referencer::position_f (me)); + if (abs (pos) - interspaces > 1) { - Direction dir = (Direction)sign (p); Interval hd = out.extent (X_AXIS); Real left_ledger_protusion = hd.length ()/4; Real right_ledger_protusion = left_ledger_protusion; @@ -175,8 +150,9 @@ Interval l_extents = Interval (hd[LEFT] - left_ledger_protusion, hd[RIGHT] + right_ledger_protusion); - out.add_molecule (Note_head::ledger_lines (me, ledger_take_space, - streepjes_i, dir, l_extents)); + out.add_molecule (Note_head::brew_ledger_lines (me, pos, interspaces, + l_extents, + ledger_take_space)); } return out; } @@ -237,23 +213,17 @@ SCM_UNDEFINED); Box bx (Interval (0, 1.0), Interval (-0.5, 0.5)); Molecule m (bx, at); - int p = (int) rint (Staff_symbol_referencer::position_f (me)); - - int sz = Staff_symbol_referencer::line_count (me)-1; - int streepjes_i = abs (p) < sz - ? 0 - : (abs (p) - sz) /2; - if (streepjes_i) - { - Direction dir = (Direction)sign (p); + int pos = (int)rint (Staff_symbol_referencer::position_f (me)); + int interspaces = Staff_symbol_referencer::line_count (me)-1; + if (abs (pos) - interspaces > 1) + { Interval hd = m.extent (X_AXIS); Real hw = hd.length ()/4; - m.add_molecule (ledger_lines (me, false, streepjes_i, dir, - Interval (hd[LEFT] - hw, - hd[RIGHT] + hw))); + Interval extent = Interval (hd[LEFT] - hw, hd[RIGHT] + hw); + m.add_molecule (brew_ledger_lines (me, pos, interspaces, extent, false)); } - + return m.smobbed_copy (); } @@ -280,4 +250,3 @@ ADD_INTERFACE (Note_head,"note-head-interface", "Note head", "accidentals-grob style stem-attachment-function"); - diff -Naur lilypond-1.5.47/lily/porrectus.cc lilypond-1.5.47.NEW/lily/porrectus.cc --- lilypond-1.5.47/lily/porrectus.cc Sun Mar 24 21:46:54 2002 +++ lilypond-1.5.47.NEW/lily/porrectus.cc Mon Mar 25 23:40:21 2002 @@ -20,6 +20,7 @@ #include "bezier.hh" #include "font-interface.hh" #include "paper-def.hh" +#include "note-head.hh" #include "math.h" // rint void @@ -82,75 +83,6 @@ } } -// Uugh. The following two functions are almost duplicated code from -// custos.cc, which itself is similar to code in note-head.cc. Maybe -// this should be moved to staff-symbol-referencer.cc? -Molecule -Porrectus::create_ledger_line (Interval x_extent, Grob *me) -{ - Molecule line; - Molecule slice = Font_interface::get_default_font (me)->find_by_name ("noteheads-ledgerending"); - Interval slice_x_extent = slice.extent (X_AXIS); - Interval slice_y_extent = slice.extent (Y_AXIS); - - // Create left ending of ledger line. - Molecule left_ending = slice; - left_ending.translate_axis (x_extent[LEFT] - slice_x_extent[LEFT], X_AXIS); - if (x_extent.length () > slice_x_extent.length ()) - line.add_molecule (left_ending); - - // Create right ending of ledger line. - Molecule right_ending = slice; - right_ending.translate_axis (x_extent[RIGHT] - slice_x_extent[RIGHT], - X_AXIS); - line.add_molecule (right_ending); - - // Fill out space between left and right ending of ledger line by - // lining up a series of slices in a row between them. - Molecule fill_out_slice = left_ending; - Real thick = slice_y_extent.length (); - Real delta_x = slice_x_extent.length () - thick; - Real xpos = x_extent [LEFT] + 2*delta_x + thick/2; // TODO: check: thick*2? - while (xpos <= x_extent[RIGHT]) - { - fill_out_slice.translate_axis (delta_x, X_AXIS); - line.add_molecule (fill_out_slice); - xpos += delta_x; - } - - return line; -} - -Molecule -Porrectus::create_streepjes (Grob *me, - int pos, - int interspaces, - Interval extent) -{ - Real inter_f = Staff_symbol_referencer::staff_space (me)/2; - int streepjes_i = abs (pos) < interspaces - ? 0 - : (abs (pos) - interspaces) /2; - Molecule molecule = Molecule(); - if (streepjes_i) - { - Direction dir = (Direction)sign (pos); - Molecule ledger_line (create_ledger_line (extent, me)); - ledger_line.set_empty (true); - Real offs = (Staff_symbol_referencer::on_staffline (me, pos)) - ? 0.0 - : -dir * inter_f; - for (int i = 0; i < streepjes_i; i++) - { - Molecule streep (ledger_line); - streep.translate_axis (-dir * inter_f * i * 2 + offs, - Y_AXIS); - molecule.add_molecule (streep); - } - } - return molecule; -} - MAKE_SCHEME_CALLBACK (Porrectus,brew_molecule,1); SCM Porrectus::brew_molecule (SCM smob) @@ -179,11 +111,9 @@ bool add_stem = to_boolean (me->get_grob_property ("add-stem")); /* - - TODO: - - ugr. why not called direction? - + * This property is called stem-direction (rather than direction) + * since it only refers to this grob's stem (or, more precisely, its + * "cauda"), but not the grob as a whole. */ SCM stem_direction_scm = me->get_grob_property ("direction"); Direction stem_direction = @@ -191,7 +121,6 @@ if (!stem_direction) stem_direction = DOWN; - /* TODO: revise name. */ @@ -285,15 +214,25 @@ molecule.translate_axis (left_position_f * space/2, Y_AXIS); - Molecule left_head_streepjes = - create_streepjes (me, (int)rint (left_position_f), interspaces, extent); - left_head_streepjes.translate_axis (left_position_f * space/2, Y_AXIS); - molecule.add_molecule (left_head_streepjes); - - Molecule right_head_streepjes = - create_streepjes (me, (int)rint (right_position_f), interspaces, extent); - right_head_streepjes.translate_axis (right_position_f * space/2, Y_AXIS); - molecule.add_molecule (right_head_streepjes); + int left_pos = (int)rint (left_position_f); + if (abs (left_pos) - interspaces > 1) + { + Molecule left_head_ledger_lines = + Note_head::brew_ledger_lines (me, left_pos, interspaces, extent, true); + left_head_ledger_lines.translate_axis (left_position_f * space/2, + Y_AXIS); + molecule.add_molecule (left_head_ledger_lines); + } + + int right_pos = (int)rint (right_position_f); + if (abs (right_pos) - interspaces > 1) + { + Molecule right_head_ledger_lines = + Note_head::brew_ledger_lines (me, right_pos, interspaces, extent, true); + right_head_ledger_lines.translate_axis (right_position_f * space/2, + Y_AXIS); + molecule.add_molecule (right_head_ledger_lines); + } return molecule.smobbed_copy(); } @@ -496,4 +435,3 @@ ADD_INTERFACE (Porrectus,"porrectus-interface", "A porrectus ligature, joining two note heads into a single grob.", "left-head right-head width add-stem auto-properties solid direction"); - diff -Naur lilypond-1.5.47/scm/ascii-script.scm lilypond-1.5.47.NEW/scm/ascii-script.scm --- lilypond-1.5.47/scm/ascii-script.scm Wed Dec 5 18:54:39 2001 +++ lilypond-1.5.47.NEW/scm/ascii-script.scm Sun Mar 24 21:29:26 2002 @@ -153,6 +153,9 @@ (if (<= dy 1) "-" "=")) (func "h-line" dx)))))) +(define (roundfilledbox breapth width depth height) + (filledbox breapth width depth height)) + (define (font-load-command name-mag command) ;; (display "name-mag: ") ;; (write name-mag) diff -Naur lilypond-1.5.47/scm/pdf.scm lilypond-1.5.47.NEW/scm/pdf.scm --- lilypond-1.5.47/scm/pdf.scm Mon Mar 18 01:11:27 2002 +++ lilypond-1.5.47.NEW/scm/pdf.scm Sun Mar 24 22:16:10 2002 @@ -137,6 +137,31 @@ (ly-number->string (+ depth height)) " re f ")) +;; TODO: +;; +;;(define (dot x y diam) +;; (let (radius (/ diam 2)) +;; (string-append (ly-number->string (x)) +;; (ly-number->string (y)) +;; (ly-number->string (radius)) +;; " ??? "))) ;; how to draw a circle in PDF? +;; +;;(define (roundfilledbox x width y height blotdiam) +;; (string-append " " +;; (dot x y blotdiam) +;; (dot (+ x width) y blotdiam) +;; (dot (+ x width) (+ y height) blotdiam) +;; (dot x (+ y height) blotdiam) +;; (filledbox (+ x (/ blotdiam 2)) (+ width (/ blotdiam 2)) y height) +;; (filledbox x width (+ y (/ blotdiam 2)) (+ height (/ blotdiam 2))))) +;; +;; +;; WORKAROUND: +;; + (define (roundfilledbox breadth width depth height) + (filledbox breadth width depth height)) +;; + (define (font-def i s) "") (define (font-switch i) "") @@ -238,6 +263,7 @@ (define end-output ,end-output) (define experimental-on ,experimental-on) (define filledbox ,filledbox) + (define roundfilledbox ,roundfilledbox) (define font-def ,font-def) (define font-switch ,font-switch) (define header-end ,header-end) @@ -269,6 +295,7 @@ ((eq? action-name 'experimental-on) experimental-on) ((eq? action-name 'ez-ball) ez-ball) ((eq? action-name 'filledbox) filledbox) + ((eq? action-name 'roundfilledbox) roundfilledbox) ((eq? action-name 'repeat-slash) repeat-slash) ((eq? action-name 'select-font) select-font) ((eq? action-name 'volta) volta) diff -Naur lilypond-1.5.47/scm/pdftex.scm lilypond-1.5.47.NEW/scm/pdftex.scm --- lilypond-1.5.47/scm/pdftex.scm Mon Mar 18 01:11:27 2002 +++ lilypond-1.5.47.NEW/scm/pdftex.scm Sun Mar 24 20:01:11 2002 @@ -158,6 +158,9 @@ "depth " (number->dim depth) "height " (number->dim height) " ")) + (define (roundfilledbox x width y height blotdiam) + (embedded-pdf ((pdf-scm 'roundfilledbox) x width y height blotdiam))) + (define (text s) (string-append "\\hbox{" (output-tex-string s) "}")) diff -Naur lilypond-1.5.47/scm/ps.scm lilypond-1.5.47.NEW/scm/ps.scm --- lilypond-1.5.47/scm/ps.scm Sat Mar 23 00:17:51 2002 +++ lilypond-1.5.47.NEW/scm/ps.scm Mon Mar 25 20:06:45 2002 @@ -160,6 +160,20 @@ (string-append (numbers->string (list breapth width depth height)) " draw_box" )) +(define (dot x y radius) + (string-append " " + (numbers->string + (list x y radius)) " draw_dot")) + +(define (roundfilledbox x width y height blotdiam) + (string-append " " + (dot (- 0 x) (- 0 y) (/ blotdiam 2)) + (dot width (- 0 y) (/ blotdiam 2)) + (dot width height (/ blotdiam 2)) + (dot (- 0 x) height (/ blotdiam 2)) + (filledbox (+ x (/ blotdiam 2)) (+ width (/ blotdiam 2)) y height) + (filledbox x width (+ y (/ blotdiam 2)) (+ height (/ blotdiam 2))))) + ;; obsolete? (define (font-def i s) (string-append @@ -227,8 +241,7 @@ ; TODO: use HEIGHT argument - -(define (start-line height) + (define (start-line height) (string-append "\n" (ly-number->string height) diff -Naur lilypond-1.5.47/scm/tex.scm lilypond-1.5.47.NEW/scm/tex.scm --- lilypond-1.5.47/scm/tex.scm Sat Mar 23 02:43:29 2002 +++ lilypond-1.5.47.NEW/scm/tex.scm Sun Mar 24 18:12:46 2002 @@ -249,6 +249,9 @@ "depth " (number->dim depth) "height " (number->dim height) " "))) +(define (roundfilledbox x y width height blotdiam) + (embedded-ps (list 'roundfilledbox x y width height blotdiam))) + (define (text s) (string-append "\\hbox{" (output-tex-string s) "}"))