lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Background Colour


From: Lukas-Fabian Moser
Subject: Re: Background Colour
Date: Tue, 18 May 2021 16:38:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1


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

[Prev in Thread] Current Thread [Next in Thread]