Frage

Lilienteich kann auf willkürliche Weise Notizen färben Verwendung

\override NoteHead #'color = #red c

mit der Standardfarbe ist schwarz. Aber ich mag es, alle Notizen nach Tonhöhe zu färben, damit meine Kinder leichter lernen können, die Noten als C, D, E, F, ... mit seiner eigenen Farbe verbunden zu sein. Das obige erlaubt mir, dies zu tun, ist aber eher ausführlich.

Gibt es eine Verknüpfung, eine Art Makros, die es mir ermöglichen, etwas in der Sicht zu tun:

redc greend bluee

Oder überschreiben Sie die Standardfarben für jede Note von Pitch, damit ich es einfach einfach tun kann:

c d e

Und hat jeder von ihnen eine andere Farbe?

War es hilfreich?

Lösung

Es gibt ein Beispiel dafür in der Schnipsel:

%Association list of pitches to colors.
#(define color-mapping
  (list
    (cons (ly:make-pitch 0 0 0) (x11-color 'red))
    (cons (ly:make-pitch 0 0 1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 1 -1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 2 0) (x11-color 'red))
    (cons (ly:make-pitch 0 2 1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 3 -1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 3 0) (x11-color 'green))
    (cons (ly:make-pitch 0 4 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 5 0) (x11-color 'green))
    (cons (ly:make-pitch 0 5 -1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 6 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 1 0) (x11-color 'blue))
    (cons (ly:make-pitch 0 3 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 -1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 5 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 6 -1/2) (x11-color 'blue))
    ))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
  (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
  (let ((color (assoc pitch color-mapping pitch-equals?)))
    (if color
      (cdr color))))

#(define (color-notehead grob)
  (pitch-to-color
    (ly:event-property (ly:grob-property grob 'cause) 'pitch)))

\score {
  \new Staff \relative c' {
    \override NoteHead #'color = #color-notehead
    c8 b d dis ees f g aes
  }
}

Sample image

Andere Tipps

Es gibt eine Frage Je nach Pitch ist es möglich, Notizköpfe zu färben? Bei der Lilypond Snippet Repository. Du erhältst die Antwort durch Klicken auf die Stange.

Ok, für das Buch Kindertastaturkurs - Buch Nr. 1 Ich habe Anfang dieses Jahres in Cambridge gekauft, ich habe jetzt diese Farbcodierung:

#(define color-mapping
  (list
    (cons (ly:make-pitch 0 0 0) (x11-color 'magenta))
    (cons (ly:make-pitch 0 1 -1/2) (x11-color 'grey))
    (cons (ly:make-pitch 0 1 0) (x11-color 'grey))
    (cons (ly:make-pitch 0 1 1/2) (x11-color 'grey))
    (cons (ly:make-pitch 0 2 0) (x11-color 'red))
    (cons (ly:make-pitch 0 2 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 3 -1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 3 0) (x11-color 'green))
    (cons (ly:make-pitch 0 4 -1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 0) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 5 0) (x11-color 'yellow))
    (cons (ly:make-pitch 0 5 -1/2) (x11-color 'yellow))
    (cons (ly:make-pitch 0 5 1/2) (x11-color 'yellow))
    (cons (ly:make-pitch 0 6 1/2) (x11-color 'purple))
    (cons (ly:make-pitch 0 6 0) (x11-color 'purple))
    (cons (ly:make-pitch 0 6 -1/2) (x11-color 'purple))))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top