Home
Random
Log in
Settings
About LilyPond wiki
LilyPond wiki
Search
Editing
Coloring staves
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
The following example demonstrates how to print individual staves with a colored background. <lilypond version="2.24.0"> %% http://lsr.di.unimi.it/LSR/Item?id=726 %% LSR contributed by Valentin: %% http://lists.gnu.org/archive/html/lilypond-user-fr/2010-10/msg00252.html bgcolor = #(define-music-function (color) (string?) #{ \override Staff.StaffSymbol.stencil = #(grob-transformer 'stencil (lambda (grob orig) (let* ((X-ext (ly:stencil-extent orig X)) (Y-ext (ly:stencil-extent orig Y))) (set! Y-ext (cons (- (car Y-ext) 2) (+ (cdr Y-ext) 2))) (ly:grob-set-property! grob 'layer -10) (ly:stencil-add (stencil-with-color (ly:round-filled-box X-ext Y-ext 0) (eval-string color)) orig)))) #}) << \new Staff { \bgcolor "blue" a'1 } % basic colors \new Staff { \bgcolor "(x11-color 'red)" b' } % x11 colors \new Staff { \bgcolor "(rgb-color 1 0.8 0.6)" c'' } % rgb colors >> </lilypond> [[Category:Staff notation]] [[Category:Editorial annotations]]
Summary:
Please note that all contributions to LilyPond wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Meta:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)