From 5b17bf7f3960204fdff6ac28122eade7edf6592a Mon Sep 17 00:00:00 2001 From: Rune Zedeler Date: Thu, 17 Oct 2002 14:11:13 +0000 Subject: [PATCH] * scm/tex.scm (zigzig-line): added. * scm/ps.scm (zigzag-line): added. * ps/music-drawing-routines.ps (subvec): added. (draw_zigzag_line): added. * lily/line-spanner.cc: Add support for #'type = #'zigzag. reading grob properties zigzag-width and zigzag-length. * input/regression/glissando.ly: Add some zig-zagged glissandi. --- ChangeLog | 14 ++++++++++ input/regression/glissando.ly | 7 ++--- lily/line-spanner.cc | 35 +++++++++++++++++++++++- ps/music-drawing-routines.ps | 44 +++++++++++++++++++++++++++++++ scm/grob-description.scm | 1 + scm/grob-property-description.scm | 13 ++++++--- scm/ps.scm | 15 +++++++++++ scm/tex.scm | 3 +++ 8 files changed, 125 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30f4795f9d..64abff0031 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-10-15 Rune Zedeler + + * scm/tex.scm (zigzig-line): added. + + * scm/ps.scm (zigzag-line): added. + + * ps/music-drawing-routines.ps (subvec): added. + (draw_zigzag_line): added. + + * lily/line-spanner.cc: Add support for #'type = #'zigzag. reading + grob properties zigzag-width and zigzag-length. + + * input/regression/glissando.ly: Add some zig-zagged glissandi. + 2002-10-15 Jan Nieuwenhuizen * scm/sodipodi.scm: Some fixes. Sketch also groks this bare-bones diff --git a/input/regression/glissando.ly b/input/regression/glissando.ly index 24b869d9bd..a98de4ff33 100644 --- a/input/regression/glissando.ly +++ b/input/regression/glissando.ly @@ -16,13 +16,14 @@ The engraver does no time-keeping, so it involves some trickery to get % gliss non gliss and c4 \glissando d e \glissando f \glissando \break % consecutive - c \glissando d \glissando e + c \glissando d, \glissando e' < { \stemUp e8 \glissando g8 } \context Voice = VB {\stemDown \repeat unfold 4 d16 } > - + \property Voice.Glissando \override #'type = #'zigzag + c4 \glissando c,, \glissando c' \glissando d } \paper{ - linewidth = 70.\mm + linewidth = 50.\mm indent = 0 \translator{ \StaffContext % makes for handier debugging diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index 1b19bf0b25..7ae32efb41 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -61,6 +61,30 @@ line_atom (Grob* me, Real thick, Real dx, Real dy) return list; } +static SCM +zigzag_atom (Grob* me, Real thick, Real dx, Real dy) +{ + Real staff_space = Staff_symbol_referencer::staff_space (me); + SCM ws = me->get_grob_property ("zigzag-width"); + SCM ls = me->get_grob_property ("zigzag-length"); + double w = (gh_number_p(ws) ? gh_scm2double(ws) : 1)*staff_space; + double l = (gh_number_p(ls) ? gh_scm2double(ls) : 1)*w; + double h = l>w/2 ? sqrt(l*l-w*w/4) : 0; + + SCM list = scm_list_n (ly_symbol2scm ("zigzag-line"), + gh_bool2scm (true), + gh_double2scm (w), + gh_double2scm (h), + gh_double2scm (thick), + gh_double2scm (dx), + gh_double2scm (dy), + SCM_UNDEFINED); + + return list; +} + + + Molecule Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy) { @@ -76,6 +100,15 @@ Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy) Interval (- 0.5* thick + (0? dy))); mol = Molecule (b, line_atom (me, thick, dx, dy)); } + else if (gh_symbol_p (type) + && type == ly_symbol2scm ("zigzag")) + { + // TODO: + Box b (Interval (-0.5* thick + (0 ? dx)), + Interval (- 0.5* thick + (0? dy))); + mol = Molecule (b, zigzag_atom (me, thick, dx, dy)); + + } else if (gh_symbol_p (type) && type == ly_symbol2scm ("trill")) { @@ -263,6 +296,6 @@ Line_spanner::brew_molecule (SCM smob) ADD_INTERFACE (Line_spanner, "line-spanner-interface", "Generic line drawn between two objects, eg. for use with glissandi. gap is measured in staff-spaces. ", - "gap dash-period dash-length thickness type"); + "gap dash-period dash-length zigzag-width zigzag-length thickness type"); diff --git a/ps/music-drawing-routines.ps b/ps/music-drawing-routines.ps index 9ca5846657..b5796e11d2 100644 --- a/ps/music-drawing-routines.ps +++ b/ps/music-drawing-routines.ps @@ -224,6 +224,50 @@ } bind def +% a b c d subvec == a-c b-d +/subvec { + 3 2 roll exch sub + 3 1 roll + sub exch +} bind def + + +% centre? zzwidth zzheight thickness x0 y0 x1 y1 +/draw_zigzag_line { + newpath + 6 dict begin + + 4 2 roll % zzuw zzh th x1 y1 x0 y0 + 2 copy + moveto + subvec % zzuw zzh th dx dy + + 2 copy euclidean_length /l exch def + l div /uy exch def + l div /ux exch def + setlinewidth + /zzh exch def + l exch div round /n exch def + n 0 gt { %if + /zzw l n 2 mul div def + { + uy zzh mul 2 div ux zzh mul -2 div rmoveto + } if + 1 1 n { + ux zzw mul uy zzh mul sub + uy zzw mul ux zzh mul add + rlineto + ux zzw mul uy zzh mul add + uy zzw mul ux zzh mul sub + rlineto + } bind for + }{ %else + pop + ux l mul uy l mul rlineto + } ifelse + stroke + end +} bind def /bracket_traject { diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 0f45647f0b..3b2fd95407 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -581,6 +581,7 @@ . ( (type . line) (gap . 0.5) + (zigzag-width . 0.75) (breakable . #t) (X-extent-callback . #f) (Y-extent-callback . #f) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index ee8029a973..83b4c5a84c 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -510,9 +510,9 @@ Like @code{bracket-visibility}, but for the number.") (grob-property-description 'tie ly:grob? "") (grob-property-description 'type symbol? " -one of: line, dashed-line, trill or dotted-line. +one of: line, dashed-line, trill, dotted-line or zigzag. -[FIXME: type is too generic for this doc, move doco to intefrace] +[FIXME: type is too generic for this doc, move doco to interface] ") (grob-property-description 'break-visibility procedure? "a function that takes the break direction and returns a cons of booleans containing (TRANSPARENT . EMPTY). @@ -543,7 +543,14 @@ no extent. (grob-property-description 'width-correct number? "width correction for (de)cresc. text spanners.") (grob-property-description 'x-gap number? "horizontal gap between notehead and tie.") (grob-property-description 'y-free number? "minimal vertical gap between slur and noteheads or stems.") -(grob-property-description 'y-offset number? "extra vertical offset for ties away from the center line.") +(grob-property-description 'y-offset number? "extra vertical offset +for ties away from the center line.") +(grob-property-description 'zigzag-length number? "The length of the +lines of a zigzag - relative to zigzag-width. a value of 1 +gives 60-degree zigzags.") +(grob-property-description 'zigzag-width number? "the width of one +zigzag-squiggle, measured in staff space. The width will be adjusted +so that the line can be constructed from a whole number of squiggles.") ;;; INTERNAL diff --git a/scm/ps.scm b/scm/ps.scm index c0989502fe..f6f20fe814 100644 --- a/scm/ps.scm +++ b/scm/ps.scm @@ -152,6 +152,21 @@ (numbers->string (list x y radius)) " draw_dot")) +(define (zigzag-line centre? zzw zzh thick dx dy) + (string-append + (if centre? "true" "false") + " " + (ly:number->string zzw) + " " + (ly:number->string zzh) + " " + (ly:number->string thick) + " 0 0 " + (ly:number->string dx) + " " + (ly:number->string dy) + " draw_zigzag_line ")) + (define (draw-line thick x1 y1 x2 y2) (string-append " 1 setlinecap diff --git a/scm/tex.scm b/scm/tex.scm index bab65d7a64..c9a32a5f65 100644 --- a/scm/tex.scm +++ b/scm/tex.scm @@ -96,6 +96,9 @@ (define (dashed-line thick on off dx dy) (embedded-ps (list 'dashed-line thick on off dx dy))) +(define (zigzag-line centre? zzw zzh thick dx dy) + (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy))) + (define (font-load-command name-mag command) (string-append "\\font\\" command "=" -- 2.39.2