[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tweaking in an engraver
From: |
Timothy Lanfear |
Subject: |
Tweaking in an engraver |
Date: |
Fri, 17 Jul 2015 21:24:39 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
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.
- Tweaking in an engraver,
Timothy Lanfear <=