I'd like an engraver that changes the colour of the note head if the pitch meets certain conditions. If the note has an existing tweak, then I can add to or override the tweak; but the note colour is unchanged for a note without a tweak. Looking at the output of display-scheme-music, the only difference is in the order of the elements in the NoteEvent. I succeeded in writing an engraver using acknowledgers but it takes more digging into the grob data structure to extract the pitch of the note.

\version "2.19.21"

colourEngraver =
#(lambda (context)
 (make-engraver
   (listeners
     ((note-event engraver event)
      (let* ((m (ly:event-property event 'music-cause))
             (tweaks (ly:music-property m 'tweaks)))
        (ly:music-set-property! m 'tweaks (assoc-set! tweaks 'color red))
        (display-scheme-music m))))))

\new Staff \with { \consists \colourEngraver }
{
  g'4 \tweak color #blue a' \tweak font-size 0 b'
}

--
Timothy Lanfear, Bristol, UK.


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to