Hi Wim,

Am 18.05.21 um 14:07 schrieb Wim van Dommelen:
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:

\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 .stencil =
     #(grob-transformer
       'stencil
       (lambda (grob default)
         (let ((X-ext (ly:stencil-extent default X))
               (Y-ext (ly:stencil-extent default Y)))
           (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)
            default))))
   #})

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

I'm not really happy yet, though, because in some cases the marking affects the spacing. A positive value of Y-padding seems to influence the skylines (e.g. of a clef), so it moves the staves further apart; and for accidentals, the X-padding messes up the spacing completely. Probably I'm changing the stencil too early, it should be changed at a later stage after positioning.

Also, it's not really clean to force the grob and the marking onto the same layer.

Lukas


Reply via email to