LSR/394

< LSR
Zur Navigation springen Zur Suche springen
PD Der Inhalt dieser Seite wurde aus dem LilyPond Snippet Repository übernommen und steht unter folgender Lizenz: CC0.
See Public Domain Help Pages for more info.
PD
Using Scheme to create a list of all available X11 colors

LSR Snippet Nr. 394

Beschreibung

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.

auto
%% http://lsr.di.unimi.it/LSR/Item?id=394
%% see also http://www.lilypond.org/doc/v2.18/Documentation/notation/list-of-colors

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LSR workaround:
#(set! paper-alist (cons '("snippet" . (cons (* 80 mm) (* 130 mm))) paper-alist))
\paper {
  #(set-paper-size "snippet")
  tagline = ##f
  indent = 0
}
\markup\vspace #.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(ly:load "x11-color.scm")

% To show all available colors (~17 pages), replace
% (take 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 x11-color-list 15))))

\markuplist \column-lines \listcolors
\markup "... (only the first 15 colors are shown)"
%% http://lsr.di.unimi.it/LSR/Item?id=394
%% see also http://www.lilypond.org/doc/v2.18/Documentation/notation/list-of-colors

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LSR workaround:
#(set! paper-alist (cons '("snippet" . (cons (* 80 mm) (* 130 mm))) paper-alist))
\paper {
  #(set-paper-size "snippet")
  tagline = ##f
  indent = 0
}
\markup\vspace #.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(ly:load "x11-color.scm")

% To show all available colors (~17 pages), replace
% (take 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 x11-color-list 15))))

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

Unterseiten

Links