Seeing the discussion on coloured lyrics, colour this and that, I realized that for some parts I do change the Background Colour of the clefs maually (using a standard ofice yellow marking (grease) pencil each time after an update print. The purpose is to have a fast recognition point for the eyes to jump to the next line and/or page.

How about:

Improved version that only tweaks the stencil after-line-breaking:

\version "2.19"

#(define (positive-number? x) (and (number? x) (positive? x)))

markerPen =
#(define-music-function
  (X-padding Y-padding grob-path)
  ((positive-number? 0.5) (positive-number? 0) key-list?)
  #{
    \override #grob-path .layer = -1
    \override #grob-path .after-line-breaking =
    #(lambda (grob)
       (let*
        ((original (ly:grob-property grob 'stencil))
         (X-ext (ly:stencil-extent original X))
         (Y-ext (ly:stencil-extent original Y)))
        (ly:grob-set-property!
         grob 'stencil
         (ly:stencil-add
          (ly:make-stencil
           (ly:stencil-expr (stencil-with-color
                             (ly:round-filled-box
                              (interval-widen X-ext X-padding)
                              (interval-widen Y-ext Y-padding)
                              1)
                             yellow))
           empty-interval empty-interval)
          original))))
  #})

\new Staff \with {
  \markerPen Clef
}
\relative {
  c'4 d \once\markerPen 0.5 0.5 Accidental es fis
  \once \markerPen Staff.BarLine
  g \markerPen 0.5 0.5 NoteHead g a
}

While this does not solve the problem of the marking affecting inter-system spacing, at least it now works fine for accidentals.

Lukas


Reply via email to