lilypond-user-fr
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Notes en couleur


From: Valentin Villenave
Subject: Re: Notes en couleur
Date: Thu, 16 Oct 2008 21:49:03 +0200

Le 16 octobre 2008 21:16, Viviane Sourdine <address@hidden> a écrit :
> bon, quand vous aurez le temps Mr Villenave (ne vous inquiétez pas ce n'est
> pas très urgent), je suis intéressée par votre réponse sur les couleurs.

La voilà, toute-prête (la solution avait en fait été postée par Jay
Anderson sur la liste anglophone il y a quelque temps).


%Association list of pitches to colors.
#(define color-mapping
 (list
   (cons (ly:make-pitch 0 0 0) (x11-color 'red))))

%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
 }
}


Cordialement,
Valentin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]