]> git.donarmstrong.com Git - lilypond.git/blobdiff - input/new/coloring-notes-depending-on-their-pitch.ly
Merge commit 'origin/dev/jneeman' into systems-per-page
[lilypond.git] / input / new / coloring-notes-depending-on-their-pitch.ly
index dd29c94f770603af03d72c650f9041f99f2ee1a1..6359c293ae18b96d5886ed6a7024323e62ce4a22 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.11.61"
+\version "2.12.0"
 \header {
   lsrtags = "pitches,editorial-annotations,really-cool"
   texidoc = "
@@ -12,41 +12,43 @@ the function used in this example even makes it possible to distinguish enharmon
 
 %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))
-   ))
 (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))))
+  (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))))
+  (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)))
-
+  (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
- }
 \new Staff \relative c' {
+    \override NoteHead #'color = #color-notehead
+    c8 b d dis ees f g aes
 }
 }