Ego*_*gen 6 lilypond music-notation
\override NoteHead #'color = #red c
Run Code Online (Sandbox Code Playgroud)
默认颜色为黑色.但我喜欢用音高为所有音符着色,这样我的孩子就可以更容易地学会识别音符,因为c,d,e,f,...与它自己的颜色有关.上面允许我这样做,但是相当冗长.
是否有一种快捷方式,某种类型的宏,允许我按照以下方式做一些事情:
redc greend bluee
Run Code Online (Sandbox Code Playgroud)
或者甚至用音高覆盖每个音符的默认颜色,这样我甚至可以简单地做:
c d e
Run Code Online (Sandbox Code Playgroud)
他们每个人都有不同的颜色?
Joe*_*oey 10
在片段中有一个例子:
%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
}
}
Run Code Online (Sandbox Code Playgroud)
