X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Documentation%2Fsnippets%2Fcoloring-notes-depending-on-their-pitch.ly;h=23b25a5523d4ff368b9be3e9b3bbccd09ef85229;hb=fa038b9595a1578f62430d8ed41bf2bbba8116e9;hp=dca9b13c7db0856569db110e1c9350956af09806;hpb=92782fde87fb68e945b9eb60cacab6c01d0397df;p=lilypond.git diff --git a/Documentation/snippets/coloring-notes-depending-on-their-pitch.ly b/Documentation/snippets/coloring-notes-depending-on-their-pitch.ly index dca9b13c7d..23b25a5523 100644 --- a/Documentation/snippets/coloring-notes-depending-on-their-pitch.ly +++ b/Documentation/snippets/coloring-notes-depending-on-their-pitch.ly @@ -1,10 +1,13 @@ -%% Do not edit this file; it is automatically -%% generated from LSR http://lsr.dsi.unimi.it +%% DO NOT EDIT this file manually; it is automatically +%% generated from LSR http://lsr.di.unimi.it +%% Make any changes in LSR itself, or in Documentation/snippets/new/ , +%% and then run scripts/auxiliar/makelsr.py +%% %% This file is in the public domain. -\version "2.13.4" +\version "2.18.0" \header { - lsrtags = "pitches, editorial-annotations" + lsrtags = "editorial-annotations, pitches, really-cool" texidoc = " It is possible to color note heads depending on their pitch and/or @@ -17,42 +20,42 @@ to distinguish enharmonics. %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 NATURAL) (x11-color 'red)) + (cons (ly:make-pitch 0 0 SHARP) (x11-color 'green)) + (cons (ly:make-pitch 0 1 FLAT) (x11-color 'green)) + (cons (ly:make-pitch 0 2 NATURAL) (x11-color 'red)) + (cons (ly:make-pitch 0 2 SHARP) (x11-color 'green)) + (cons (ly:make-pitch 0 3 FLAT) (x11-color 'red)) + (cons (ly:make-pitch 0 3 NATURAL) (x11-color 'green)) + (cons (ly:make-pitch 0 4 SHARP) (x11-color 'red)) + (cons (ly:make-pitch 0 5 NATURAL) (x11-color 'green)) + (cons (ly:make-pitch 0 5 FLAT) (x11-color 'red)) + (cons (ly:make-pitch 0 6 SHARP) (x11-color 'red)) + (cons (ly:make-pitch 0 1 NATURAL) (x11-color 'blue)) + (cons (ly:make-pitch 0 3 SHARP) (x11-color 'blue)) + (cons (ly:make-pitch 0 4 FLAT) (x11-color 'blue)) + (cons (ly:make-pitch 0 5 SHARP) (x11-color 'blue)) + (cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue)))) %Compare pitch and alteration (not octave). #(define (pitch-equals? p1 p2) - (and + (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 + (pitch-to-color (ly:event-property (event-cause grob) 'pitch))) \score { \new Staff \relative c' { - \override NoteHead #'color = #color-notehead + \override NoteHead.color = #color-notehead c8 b d dis ees f g aes } }