Jump to content

Drawing boxes around grobs: Difference between revisions

From LilyPond wiki
mNo edit summary
mNo edit summary
 
Line 21: Line 21:


[[Category:Editorial annotations]]
[[Category:Editorial annotations]]
[[Category:Scheme]]
[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Included in the official documentation]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]
[[Category:Snippet]]

Latest revision as of 06:46, 12 December 2025

The stencil property can be overridden to draw a box around arbitrary grobs, either using \override or \tweak.

\version "2.24"

\relative c'' {
  \once \override TextScript.stencil =
    #(make-stencil-boxer 0.1 0.3 ly:text-interface::print)
  c'4^"foo"

  \tweak Stem.stencil
    #(make-stencil-boxer 0.05 0.25 ly:stem::print)
  b8

  c4.^"bar" c4

  \override Score.RehearsalMark.stencil =
    #(make-stencil-boxer 0.15 0.3 ly:text-interface::print)
  \mark \default
  c1
}