开发者

Changing all the colors in Lilypond

In Lilypond I can change the开发者_开发问答 color of one type of object with a line like

\override Staff.Clef #'color = #(rgb-color 0.4 0.5 0.6)

I'd like to have everything in the same (non-default) color, but I neither found a list of all the objects I could color nor did I find a command to change all the colors at once. Could anybody please point me to either?


The LilyPond Snippet Repository has a solution that iterates through the list of objects contained in all-grob-descriptions:

#(define (override-color-for-all-grobs color)
  (lambda (context)
   (let loop ((x all-grob-descriptions))
    (if (not (null? x))
     (let ((grob-name (caar x)))
      (ly:context-pushpop-property context grob-name 'color color)
      (loop (cdr x)))))))

% Example of usage:
\relative c' {
  \applyContext #(override-color-for-all-grobs (x11-color 'blue))
  c4\pp\< d e f
  \grace { g16[( a g fis]) } g1\ff\!
}

Note that this will change the color of every graphical object only if you run it in the proper context (Score, I think, will generally suffice), so you may need to do the following if you're in the middle of, say, a Voice context:

\stopStaff
\context Score
\applyContext #(override-color-for-all-grobs (x11-color 'blue))
\startStaff


The list of graphical objects you need is at the bottom of this page. So a simple albeit tedious approach would be to iterate through all those objects you use, e.g.

\override Staff.Clef     #'color = #(rgb-color 0.4 0.5 0.6)
\override Staff.NoteHead #'color = #(rgb-color 0.4 0.5 0.6)
\override Staff.Beam     #'color = #(rgb-color 0.4 0.5 0.6)
\override Staff.Slur     #'color = #(rgb-color 0.4 0.5 0.6)

etc.

There's probably a much better way but I can't figure it out. Alternatively, as has been suggested before you could consider doing some post-processing on the output from Lilypond, which may be simpler depending on the tools you have available.

I strongly recommend that you read the excellent documentation, in particular how to navigate the Internals Reference as covered by the Learning Manual and the Notation Reference

Also you may obtain a better answer from the lilypond-user mailing list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜