Using Scheme to create a list of all available X11 colors (obsolete in 2.25)

(Redirected from LSR 394)

LilyPond supports named colors through x11-color, the corresponding color names can be found in the file scm/x11-color.scm. Using Scheme, one can easily create a LilyPond file displaying (all) supported color names with an example of each color automatically. The way to do this is loading the scolor.scm file and then creating a \markup for each color definition.

This snippet is obsolete in version 2.25 since the documentation now contains a list of colors that also displays a square with each color, see List of colors.

\version "2.24"

% To show all available colors (~17 pages), replace
% (take (@@ (lily) x11-color-list) 15) by x11-color-list
#(define-markup-list-command (listcolors layout props) ()
  (interpret-markup-list layout props
    (map (lambda (colorspec)
      (markup #:with-color (x11-color (car colorspec))
              #:filled-box '(-0.5 . 10) '(-1 . 3) 1
              (symbol->string (car colorspec))))
      (take (@@ (lily) x11-color-list) 15))))

\markuplist \column-lines \listcolors
\markup "... (only the first 15 colors are shown)"