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

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

Re: Notes en couleur


From: Jean Abou Samra
Subject: Re: Notes en couleur
Date: Sun, 27 Nov 2022 16:00:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0

Le 26/11/2022 à 16:26, Christian LE BARS a écrit :
Bonjour a tous.

J'aimerais coloriser les têtes de notes altérées.

Voici le code

\relative c'
 {
  \clef treble
  \Global
  \override NoteHead.color = #magenta fis'8  \override NoteHead.color = #black e
  \override NoteHead.color = #magenta fis4  \override NoteHead.color = #black d8
  a b2 8 g a2

 \override NoteHead.color = # magenta fis4 \override NoteHead.color = #black
  <b, g'> \override NoteHead.color = #magenta  fis' \override NoteHead.color = #black g
  e4. e'8 \override NoteHead.color = # magenta cis \override NoteHead.color = #black a8
  4 g \override NoteHead.color = #magenta fis  \override NoteHead.color = #black g
  < fis  a> <g b> a8 b a e g   \override NoteHead.color = #magenta fis fis

\override NoteHead.color = #black g
  \override NoteHead.color = #magenta fis \override NoteHead.color = #black d e4 d2.
 }

Plutôt qu'écrire \override NoteHead.color = #magenta, j'aimerai écrire par exemple: Vert

et Vert contiendrait la chaine : \override NoteHead.color = #magenta

de plus pour l'accord <fis a> j'aimerai avoir que le fis en magenta pas tout l'accord

J'espère que ma demande est claire.





Bonjour Christian,

Tu peux tout simplement mettre le \override dans une variable (oui,
ça marche !).

vert = \override NoteHead.color = #magenta

(Au passage, il ne vaudrait pas mieux renommer la variable
en « magenta » plutôt que « vert » ?)

Mais est-ce que tu ne serais pas encore plus content que
ce soit automatique ?


\version "2.22.2"

\layout {
  \context {
    \Staff
    \consists
      #(lambda (context)
         (make-engraver
          (acknowledgers
           ((rhythmic-head-interface engraver grob source-engraver)
            (let* ((cause (event-cause grob))
                   (pitch (ly:event-property cause 'pitch))
                   (alter (ly:pitch-alteration pitch)))
              (if (not (zero? alter))
                  (let ((step-alter (cons (ly:pitch-steps pitch)
                                          alter))
                        (key-sig (ly:context-property context 'keyAlterations)))
                    (if (not (member step-alter key-sig))
                        (set! (ly:grob-property grob 'color)
                              (assq-ref (ly:grob-property grob 'details)
                                        'altered-color))))))))))
  }
}

alteredColor = \override NoteHead.details.altered-color = \etc

%%% Exemple :

\relative {
  \key d \minor
  \alteredColor #magenta
  d'8 e fis g a bes a fis
}




Cordialement,
Jean


Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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