莉莲 可以以任意方式彩色笔记 使用

\override NoteHead #'color = #red c

默认颜色为黑色。但是我喜欢按音调上色,以便我的孩子可以更轻松地学会将音符识别为C,d,e,f,...与其自身的颜色相关联。以上允许我这样做,但虽然是冗长的。

是否有捷径,某种宏,使我可以按照以下方式进行操作:

redc greend bluee

甚至通过音调覆盖每个音符的默认颜色,以便我什至可以简单地做:

c d e

他们每个人都有不同的颜色吗?

有帮助吗?

解决方案

有一个例子 摘要:

%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

其他提示

有一个问题 可以根据音高的音调颜色音符头吗?Lilypond片段存储库. 。你得到 答案 通过单击脚踏板。

好的,对于这本书 儿童键盘课程 - 书#1 我今年早些时候在剑桥购买了此颜色编码:

#(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))))
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top