Jump to content

Changing properties for individual grobs: Difference between revisions

From LilyPond wiki
No edit summary
m New category
Tags: Mobile edit Mobile web edit
 
Line 25: Line 25:
[[Category:Scheme]]
[[Category:Scheme]]
[[Category:Really cool]]
[[Category:Really cool]]
[[Category:Included in the official documentation]][[Category:Snippet]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]

Latest revision as of 23:16, 21 November 2025

The \applyOutput command allows the tuning of any layout object, in any context. It requires a Scheme function with three arguments.

\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
}