I think it’s confusing to set the “foreground colour” via `page-color`, since that suggests affecting the colour of the background itself. Hence my proposal of `print-color` for the “foreground”.
Revised file attached. I ended up with a weird special-case treatment for X11 colours in my `\color-sample` markup function, and realised just now that this doesn’t help anyone wanting finer control and RGB color values. Oh well, I’ve spent enough time on this for now…
In case I don’t hear back, I’ll probably add it to the LSR. Best, Simon On 02.01.25 16:47, Ya Gloops wrote:
Hello and Happy New Year! Is it possible to change the background color? For example background-color = #redLe jeudi 2 janvier 2025 à 16:32:17 UTC+1, Simon Albrecht <simon.albre...@mail.de> a écrit :Hi Harm, On 01.01.25 14:00, Thomas Morley wrote: > This should always give a black background, all other objects should > be colored with `page-color`, apart from objects which already have a > color. this is great! How about the attached file for an LSR snippet? Do you want to upload it yourself? Best, Simon
test-whiteonblack-harm-2025-for-lsr.pdf
Description: Adobe PDF document
\version "2.24.0" \paper { %background-color = #(x11-color "gray20") print-color = #white #(define (page-post-process layout pages) (let ((backgroundcolor (ly:output-def-lookup $defaultpaper 'background-color black)) (color (ly:output-def-lookup $defaultpaper 'print-color #f))) (when (color? color) (for-each (lambda (page) (let ((page-stencil (ly:prob-property page 'stencil))) (set! (ly:prob-property page 'stencil) (ly:stencil-add (stencil-with-color (make-filled-box-stencil (ly:stencil-extent page-stencil X) (ly:stencil-extent page-stencil Y)) backgroundcolor) (stencil-with-color page-stencil color))))) pages)))) } \header { title = \markup { Rendering LilyPond files white on black } subtitle = \markup { for screen and projector use } } #(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 \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 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 . -7) \with-color #white \filled-box #'(0 . 50) #'(0 . 10) #.7 \left-column { \color-sample "darkslategray" \color-sample "midnightblue" \color-sample #(x11-color "gray20") } \vspace #.3 \line { Appendix 7 of the Notation Reference lists available colors. } \strut } { 1 }