Oops.

\slurSolid needs to be added to the beginning
of the music function in case \slurDashed was
called before \slurSolidDashed (as an example).

- Mark



      
\version "2.13.0"

halfAndHalfSlur =
#(define-music-function
   (parser location switch-point start-dashed?)
   (number? boolean?)
#{
  \slurSolid
  % set 'layer to -2 if you're also using my \hideCurvesFrom macro:
  \override Slur #'layer = #-1
  \override Slur #'stencil =
  #(lambda (grob)
    (let* ((grob-copy grob)
           (switch-point $switch-point)
           (this-stil (ly:slur::print grob))
           (stil-x-ext (ly:stencil-extent this-stil 0))
           (stil-y-ext (ly:stencil-extent this-stil 1))
           
           ; kludge: extents don't completely cover the slur!
           (stil-x-ext (cons (- (car stil-x-ext) 1)
                             (+ (cdr stil-x-ext) 1)))
           (stil-y-ext (cons (- (car stil-y-ext) 1)
                             (+ (cdr stil-y-ext) 1)))
                             
           (stil-w (- (cdr stil-x-ext) (car stil-x-ext)))
           (stil-h (- (cdr stil-y-ext) (car stil-y-ext)))
                       
           (box-w (if $start-dashed?
                      (* stil-w switch-point)
                      (* stil-w (- 1 switch-point))))
           (box-x0 (if $start-dashed?
                       (car stil-x-ext)
                       (- (cdr stil-x-ext)
                          box-w)))
           (box-y0 (car stil-y-ext))
           (box-h stil-h))
           
      ;; values come from slurDashed definition in property-init.ly:
      (ly:grob-set-property! grob-copy 'dash-period 0.75)
      (ly:grob-set-property! grob-copy 'dash-fraction 0.4)
      
      (ly:stencil-add
      
       ;; first the solid slur:
       this-stil
       
       ;; then the white box covering part of the solid slur:
       (ly:make-stencil
        (list 'embedded-ps
         (ly:format
          (string-append "gsave\n"
                         "currentpoint translate\n"
                         "1 setgray\n"
                         "~a ~a ~a ~a rectfill\n"
                         "grestore\n")
          box-x0
          box-y0
          box-w
          box-h))
        stil-x-ext
        stil-y-ext)
        
       ;; then the dashed slur:
       (ly:slur::print grob-copy)
       )))
#})

slurDashedSolid = {
  \halfAndHalfSlur #0.5 ##t
}

slurSolidDashed = {
  \halfAndHalfSlur #0.5 ##f
}

slurSolid = {
  % commenting this line out keeps slurs in a lower layer:
  \revert Slur #'layer
  \revert Slur #'stencil
  \slurSolid
}

slurDashed = {
  % commenting this line out keeps slurs in a lower layer:
  \revert Slur #'layer
  \revert Slur #'stencil
  \slurDashed
}

slurDotted = {
  % commenting this line out keeps slurs in a lower layer:
  \revert Slur #'layer
  \revert Slur #'stencil
  \slurDashed
}


%%%%%% EXAMPLE %%%%%%

% {
\relative {
  \slurDashedSolid f4( d e f)
  \slurDashed f4( d e f)
  \slurSolidDashed f4( d e f)
  \slurSolid f4( d e f)
}
%}
_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to