]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/tex.scm (zigzig-line): added.
authorRune Zedeler <rune@lilypond.org>
Thu, 17 Oct 2002 14:11:13 +0000 (14:11 +0000)
committerRune Zedeler <rune@lilypond.org>
Thu, 17 Oct 2002 14:11:13 +0000 (14:11 +0000)
* 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
input/regression/glissando.ly
lily/line-spanner.cc
ps/music-drawing-routines.ps
scm/grob-description.scm
scm/grob-property-description.scm
scm/ps.scm
scm/tex.scm

index 30f4795f9d775e5611988464bebe792a9c2fe5fc..64abff00317c8f4d8fc9333ed2447d8155099a07 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-10-15  Rune Zedeler  <rune@zedeler.dk>
+
+       * 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  <janneke@gnu.org>
 
        * scm/sodipodi.scm: Some fixes.  Sketch also groks this bare-bones
index 24b869d9bda90acc866c2f4722c63ab8063a8bb3..a98de4ff334d6adb54fdf3e99b0b8ea510ea5f18 100644 (file)
@@ -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
index 1b19bf0b2576ff212e3b236d720a4c5db7b524dd..7ae32efb41ce90045758bfaa3c5e3c7079a961ed 100644 (file)
@@ -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), 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) ,0.5* thick+ (0 >? dx)),
+            Interval (- 0.5* thick + (0<? dy), 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");
 
 
index 9ca584665709ecfc7cdb7085be8eb9ed3a153ab8..b5796e11d283e4872edb6f5226eaa82d68b0fae1 100644 (file)
 } 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 
 { 
index 0f45647f0bd5e29dd543c5c970fd3a9653e25cbd..3b2fd95407b967f7f6bef8c875ecc63cc9a4b9de 100644 (file)
      . (
        (type . line)
        (gap . 0.5)
+       (zigzag-width . 0.75)
        (breakable . #t)
        (X-extent-callback . #f)
        (Y-extent-callback . #f)                         
index ee8029a9730732d24c431e52106590fc620f9ced..83b4c5a84ccf2cd04e42bc080add65f9e2e77bd7 100644 (file)
@@ -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
index c0989502fe5be1f29a549db1701f91546cb3e489..f6f20fe81400d3203d3f383962ffb883bb0dd470 100644 (file)
    (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
index bab65d7a641321460f82aa8107e544d6714b25ab..c9a32a5f652cb6659af23d24dd291a70b299aedf 100644 (file)
@@ -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 "="