Changing properties for individual grobs: Difference between revisions
Appearance
extend documentation |
mNo edit summary |
||
| Line 3: | Line 3: | ||
In the example below, function <code>mc-squared</code> is executed for all <code>NoteHead</code> grobs (within the current <code>Voice</code> context) at the current time step; the function modifies the grob's <code>stencil</code>, using the <code>staff-position</code> property to replace some pitches with markup. | In the example below, function <code>mc-squared</code> is executed for all <code>NoteHead</code> grobs (within the current <code>Voice</code> context) at the current time step; the function modifies the grob's <code>stencil</code>, using the <code>staff-position</code> property to replace some pitches with markup. | ||
See the [ | See the [{{LILYSTABLEDOC}}/extending/running-a-function-on-all-layout-objects ‘Extending’ manual] for more information. | ||
<lilypond version="2.24"> | <lilypond version="2.24"> | ||
Latest revision as of 05:22, 12 January 2026
The \applyOutput command allows the tuning of any layout object, in any context. It requires a Scheme function with three arguments.
In the example below, function mc-squared is executed for all NoteHead grobs (within the current Voice context) at the current time step; the function modifies the grob's stencil, using the staff-position property to replace some pitches with markup.
See the ‘Extending’ manual for more information.
\version "2.24"
#(define (mc-squared grob grob-origin context)
(let ((sp (ly:grob-property grob 'staff-position)))
(ly:grob-set-property!
grob 'stencil
(grob-interpret-markup grob
#{ \markup \lower #0.5
#(case sp
((-5) "m")
((-3) "c ")
((-2) #{ \markup \teeny \bold 2 #})
(else "bla")) #}))))
\relative c' {
<d f g b>2
\applyOutput Voice.NoteHead #mc-squared
<d f g b>2
}