[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: portée à plusieurs couleurs
From: |
Pierre Perol-Schneider |
Subject: |
Re: portée à plusieurs couleurs |
Date: |
Tue, 23 Apr 2019 13:39:11 +0200 |
Bonjour Joël,
Oui, c'est possible (cf. LSR :http://lsr.di.unimi.it/LSR/Item?id=700)
%%% test:
\version "2.19.83"
#(define-public ((color-staff-lines . rest) grob)
(define (index-cell cell dir)
(if (equal? dir RIGHT)
(cdr cell)
(car cell)))
(define (index-set-cell! x dir val)
(case dir
((-1) (set-car! x val))
((1) (set-cdr! x val))))
(let* ((common (ly:grob-system grob))
(span-points '(0 . 0))
(thickness (* (ly:grob-property grob 'thickness 1.0)
(ly:output-def-lookup (ly:grob-layout grob)
'line-thickness)))
(width (ly:grob-property grob 'width))
(line-positions (ly:grob-property grob 'line-positions))
(staff-space (ly:grob-property grob 'staff-space 1))
(line-stencil #f)
(total-lines empty-stencil)
;; use a local copy of colors list, since
;; stencil creation mutates list
(colors rest))
(for-each
(lambda (dir)
(if (and (= dir RIGHT)
(number? width))
(set-cdr! span-points width)
(let* ((bound (ly:spanner-bound grob dir))
(bound-ext (ly:grob-extent bound bound X)))
(index-set-cell! span-points dir
(ly:grob-relative-coordinate bound common X))
(if (and (not (ly:item-break-dir bound))
(not (interval-empty? bound-ext)))
(index-set-cell! span-points dir
(+ (index-cell span-points dir)
(index-cell bound-ext dir))))))
(index-set-cell! span-points dir (- (index-cell span-points dir)
(* dir thickness 0.5))))
(list LEFT RIGHT))
(set! span-points
(coord-translate span-points
(- (ly:grob-relative-coordinate grob common X))))
(set! line-stencil
(make-line-stencil thickness (car span-points) 0 (cdr
span-points) 0))
(if (pair? line-positions)
(for-each (lambda (position)
(let ((color (if (pair? colors)
(car colors)
#f)))
(set! total-lines
(ly:stencil-add
total-lines
(ly:stencil-translate-axis
(if (color? color)
(ly:stencil-in-color line-stencil
(first color)
(second color)
(third color))
line-stencil)
(* position staff-space 0.5) Y)))
(and (pair? colors)
(set! colors (cdr colors)))))
line-positions)
(let* ((line-count (ly:grob-property grob 'line-count 5))
(height (* (1- line-count) (/ staff-space 2))))
(do ((i 0 (1+ i)))
((= i line-count))
(let ((color (if (and (pair? colors)
(> (length colors) i))
(list-ref colors i)
#f)))
(set! total-lines (ly:stencil-add
total-lines
(ly:stencil-translate-axis
(if (color? color)
(ly:stencil-in-color line-stencil
(first color)
(second color)
(third color))
line-stencil)
(- height (* i staff-space)) Y)))))))
total-lines))
\score {
<<
\new MensuralStaff \with {
\override Clef.stencil = #
(lambda (grob)(grob-interpret-markup grob
#{ \markup
\fontsize #-2
\raise #2.6
\concat
{ \hspace #1 \musicglyph #"clefs.mensural.g"
\hspace #-1.5 \lower #2.6 \musicglyph
#"clefs.mensural.c"
\hspace #-0.75 \lower #5.4 \musicglyph
#"clefs.petrucci.f"
}
#}))
clefPosition = #0
middleCPosition = #0
middleCClefPosition = #0
\omit TimeSignature
\override StaffSymbol.staff-space = #1.4
\override StaffSymbol.line-count = #11
\override StaffSymbol.stencil = #(color-staff-lines black black
black red black green black cyan)
}
{ s }
>>
\layout {
ragged-last = ##f
indent = 0
}
}
%%% test end
Cordialement,
Pierre
Le mar. 23 avr. 2019 à 12:11, <address@hidden> a écrit :
>
> Bonjour à toutes et à tous et merci pour votre formidable travail !
>
>
> Je souhaite pouvoir colorer individuellement la ligne correspondant aux trois
> clefs sur une portée de 11 lignes (par exemple la ligne de la clef d'ut en
> rouge, la ligne de la clef de sol en orange et celle de la clef de fa en
> bleu).
> Je vous montre ce que j'ai fait pour le moment, sans les couleurs donc...
> Je n'ai pas l'impression que l'on puisse toucher individuellement aux
> paramètres de couleur des lignes de portées : est-ce que je me trompe ?
>
> Bien cordialement à toute la communauté,
>
> Joël Gauvrit
>
>
> \score {
> <<
> \new MensuralStaff \with {
>
> \override Clef.stencil = #
> (lambda (grob)(grob-interpret-markup grob
> #{ \markup
> \fontsize #-2
> \raise #2.6
> \concat
> { \hspace #1 \musicglyph #"clefs.mensural.g"
> \hspace #-1.5 \lower #2.6 \musicglyph
> #"clefs.mensural.c"
> \hspace #-0.75 \lower #5.4 \musicglyph
> #"clefs.petrucci.f"
> }
>
>
> #}))
> clefPosition = #0
> middleCPosition = #0
> middleCClefPosition = #0
>
> \omit Staff.TimeSignature
> \override StaffSymbol.staff-space = #1.4
> \override StaffSymbol.line-count = #11
> }
>
> { }
> >>
> \layout {
> ragged-last = ##f
> indent = 0
> }
> }
>
> _______________________________________________
> liste de diffusion lilypond-user-fr
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user-fr