Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
LilyPond wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Dark Mode Sheet Music
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
For screen projection and displays of all sorts it’s often preferable to leave the background dark or black and show the content in white, in order to obtain better contrast for difficult lighting conditions or to be easier on the eyes. This snippet introduces two paper variables, print-color and background-color, that will be applied to all printed objects and to the background of the page, respectively. Any objects whose color has been manually specified won’t have print-color applied. NB: This implementation is incompatible with whiteout in 2.24.0, and requires explicit overriding of whiteout-color (or the optional color argument to the \whiteout markup command) in recent 2.25 development versions. <lilypond version="2.24.0" full> \version "2.24.0" % Concept and UI by Simon Albrecht % page-post-process implementation thanks to Thomas Morley: % https://lists.gnu.org/archive/html/lilypond-user/2025-01/msg00018.html \paper { tagline = ##f background-color = #(x11-color "gray20") print-color = "ivory" #(define (page-post-process layout pages) (let ((print-color (ly:output-def-lookup $defaultpaper 'print-color #f)) (background-color (ly:output-def-lookup $defaultpaper 'background-color #f))) (for-each (lambda (page) (let ((page-stencil (ly:prob-property page 'stencil))) (set! (ly:prob-property page 'stencil) (if (not background-color) (stencil-with-color page-stencil print-color) (ly:stencil-add (stencil-with-color (make-filled-box-stencil (ly:stencil-extent page-stencil X) (ly:stencil-extent page-stencil Y)) background-color) (stencil-with-color page-stencil print-color)))))) pages))) } \header { title = \markup { Rendering LilyPond files white on black } subtitle = \markup { for screen and projector use } } % this sampling function is quite crude and doesn’t cover custom RBG values % (except for "grayNN" equivalents) #(define-markup-command (color-sample layout props clr) (color?) (let ((name (if (string? clr) (string-append "\"" clr "\"") (string-append "#(x11-color \"gray" (number->string (inexact->exact (* 100 (car clr)))) "\")")))) (interpret-markup layout props #{\markup \line \general-align #Y #-1 \with-color $clr { \beam #5 #0 #2 \with-dimension-from #Y \typewriter "yl" \typewriter $name }#}))) \markup \left-column { \strut \line { Any objects with unspecified colour are printed according to \typewriter print-color. } \vspace #.3 \line { Here are samples of pure white along with other colours that may be } \line { more traditional, more pleasant or easier on the eye: } \typewriter { \color-sample "white" \color-sample "ivory" \color-sample "antiquewhite" \color-sample "navajowhite" } \vspace #.3 \line { The background color may also be adjusted through the paper variable \typewriter background-color. Ideas: } \vspace #.3 \combine \translate #'(-.7 . -10) \with-color #white \filled-box #'(0 . 50) #'(0 . 13) #.7 \left-column { \color-sample "black" \color-sample #(x11-color "gray20") \color-sample "midnightblue" \color-sample "darkslategray" } \vspace #.3 \line { Appendix 7 of the Notation Reference lists available colors. } \strut } { 1 } \addlyrics { test } </lilypond> [[Category:Paper and layout]] [[Category:Stylesheet]]
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)
Search
Search
Editing
Dark Mode Sheet Music
Add topic