[Top][All Lists]

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

Re: Tweaking in an engraver

From: Paul Morris
Subject: Re: Tweaking in an engraver
Date: Fri, 17 Jul 2015 16:49:30 -0400

> On Jul 17, 2015, at 4:24 PM, Timothy Lanfear <address@hidden> wrote:
> I'd like an engraver that changes the colour of the note head if the pitch 
> meets certain conditions.

How about the following?  It shows how to access the pitch and change the 
“default" note head color.  From there you can extend this to change the color 
based on the pitch.


\version "2.19.22"

colourEngraver = 
#(lambda (context)
     ((note-head-interface engraver grob source-engraver)
      (let* ((event (ly:grob-property grob 'cause))
             (pitch (ly:event-property event 'pitch))
             ;; (m (ly:event-property event 'music-cause))
             ;; (tweaks (ly:music-property m 'tweaks))
        (display pitch)
        (ly:grob-set-property! grob 'color red)

        ;; (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'

reply via email to

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