Coloring objects - GNU LilyPond
Description: GNU LilyPond

Next: Parentheses, Previous: Analysis brackets, Up: Educational use

#### 8.5.7 Coloring objects

Individual objects may be assigned colors. You may use the color names listed in the List of colors.

>          \override NoteHead #'color = #red
>          c4 c
>          \override NoteHead #'color = #(x11-color 'LimeGreen)
>          d
>          \override Stem #'color = #blue
>          e

The full range of colors defined for X11 can be accessed by using the scheme function x11-color. The function takes one argument that can be a symbol

    \override Beam #'color = #(x11-color 'MediumTurquoise)

or a string

    \override Beam #'color = #(x11-color "MediumTurquoise")

The first form is quicker to write and is more efficient. However, using the second form it is possible to access X11 colors by the multi-word form of its name

    \override Beam #'color = #(x11-color "medium turquoise")

If x11-color cannot make sense of the parameter then the color returned defaults to black. It should be obvious from the final score that something is wrong.

This example illustrates the use of x11-color. Notice that the stem color remains black after being set to (x11-color 'Boggle), which is deliberate nonsense.

>          {
>            \override Staff.StaffSymbol #'color = #(x11-color 'SlateBlue2)
>            \set Staff.instrument = \markup {
>              \with-color #(x11-color 'navy) "Clarinet"
>            }
>            \time 2/4
>            gis''8 a''
>            \override Beam #'color = #(x11-color "medium turquoise")
>            gis'' a''
>            \override NoteHead #'color = #(x11-color "LimeGreen")
>            gis'' a''
>            \override Stem #'color = #(x11-color 'Boggle)
>            gis'' a''
>          }

##### See also

Appendix: List of colors.

##### Bugs

Not all x11 colors are distinguishable in a web browser. For web use normal colors are recommended.

An x11 color is not necessarily exactly the same shade as a similarly named normal color.

Notes in a chord cannot be colored with `\override`; use `\tweak` instead. See Objects connected to the input for details.

This page is for LilyPond-2.8.8 (stable-branch).

Other languages: English.
Using automatic language selection.