[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Un peu de couleur...
From: |
Jean Abou Samra |
Subject: |
Re: Un peu de couleur... |
Date: |
Mon, 13 Dec 2021 14:13:37 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 |
Le 13/12/2021 à 11:21, Vincent Gay a écrit :
Le 12/12/2021 à 18:44, Christian LE BARS a écrit :
bonjour Vincent. Super ta partoche!!
Puis -je en avoir un exemplaire, moi aussi a des fin didactique.
Code ci-dessous. Quelques commentaires :
1) J'ai copié / collé le code fourni par Jean ( sans l'exemple de fin)
dans un fichier que j'ai appelé staffColor.ly et que j'appelle par un
\include. *Attention* : si on appelle le fichier sans autre
modifications toutes les portées sont coloriées en noir. Commencez
donc votre code par \staffColor white. (Jean, serait-il possible que
le blanc soit la couleur par défaut si non définie ?)
Effectivement, je ne m'en étais pas rendu compte.
Voici une version corrigée et simplifiée :
\version "2.22.1"
#(define (define-grob! grob-name grob-entry)
(set! all-grob-descriptions
(cons ((@@ (lily) completize-grob-entry)
(cons grob-name grob-entry))
all-grob-descriptions)))
#(define (staff-colorizer::print grob)
(let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
(left (ly:spanner-bound grob LEFT))
(right (ly:spanner-bound grob RIGHT))
(refp (ly:grob-system grob))
(spacing-pair (ly:grob-property grob 'spacing-pair))
(coord-adjust (ly:grob-relative-coordinate grob refp X))
(x-span (cons (- (interval-end
(ly:paper-column::break-align-width
left
(car spacing-pair)))
coord-adjust)
(- (interval-start
(ly:paper-column::break-align-width
right
(cdr spacing-pair)))
coord-adjust)))
(y-span (ly:grob-extent staff-symbol staff-symbol Y)))
(make-filled-box-stencil x-span y-span)))
#(define-grob!
'StaffColorizer
`((stencil . ,staff-colorizer::print)
(layer . -1)
(spacing-pair . (staff-bar . staff-bar))
(meta . ((class . Spanner)
(interfaces . (text-interface))))))
#(set-object-property! 'staffColor 'translation-type? color?)
#(define (Staff_colorizer_engraver context)
(let ((current-color #f)
(spanner #f))
(make-engraver
((process-music engraver)
(let ((color (ly:context-property context 'staffColor #f)))
(if (and color
(not (equal? color current-color)))
(let ((column (ly:context-property context
'currentCommandColumn)))
(set! current-color color)
(if spanner
(ly:spanner-set-bound! spanner RIGHT column))
(set! spanner (ly:engraver-make-grob engraver
'StaffColorizer '()))
(ly:grob-set-property! spanner 'color current-color)
(ly:spanner-set-bound! spanner LEFT column)))))
((finalize engraver)
(if spanner
(let ((column (ly:context-property context
'currentCommandColumn)))
(ly:spanner-set-bound! spanner RIGHT column)))))))
\layout {
\context {
\Global
\grobdescriptions #all-grob-descriptions
}
\context {
\Staff
\consists #Staff_colorizer_engraver
}
}
staffColor = \set Staff.staffColor = \etc
{
\staffColor red
c'1
\staffColor green
c'2 4 \staffColor cornflowerblue 4
}
Cordialement,
Jean
- Un peu de couleur..., Vincent Gay, 2021/12/12
- Re: Un peu de couleur..., Jean Abou Samra, 2021/12/12
- Re: Un peu de couleur..., Vincent Gay, 2021/12/12
- Re: Un peu de couleur..., Vincent Gay, 2021/12/12
- Re: Un peu de couleur..., Christian LE BARS, 2021/12/12
- Re: Un peu de couleur..., Vincent Gay, 2021/12/13
- Re: Un peu de couleur..., Vincent Gay, 2021/12/13
- Re: Un peu de couleur...,
Jean Abou Samra <=
- Re: Un peu de couleur..., Vincent Gay, 2021/12/13
- Re: Un peu de couleur..., Christian LE BARS, 2021/12/13
- Re: Un peu de couleur..., Jean Abou Samra, 2021/12/13
- Re: Un peu de couleur..., nicolas lehembre, 2021/12/12