| [ << Tweaks and overrides ] | [Top][Contents] | [ Workaround >> ] |
| [ < Imbrications de regroupements de portées ] | [ Up: Tweaks and overrides ] | [ Affichage du numéro de répétition en pourcent > ] |
Personnalisation de certains types d’articulation
On peut parfois vouloir modifier un seul type d’articulation. Bien que
ce soit tout à fait faisable avec un \tweak, cela devient vite
fastidieux d’affiner chaque occurrence d’un même signe dans toute une
partition. Le code ci-dessous illustre la manière de modifier des
articulations grâce à une liste de réglages personnalisés. Ceci peut
servir à créer des feuilles de style.
La fonction \customScripts ici proposée peut se placer, depuis
la version 2.16.2, dans un bloc \layout.
#(define (custom-script-tweaks ls) (lambda (grob) (let* ((type (ly:event-property (ly:grob-property grob 'cause) 'articulation-type)) (tweaks (assoc-ref ls type))) (when tweaks (for-each (lambda (x) (ly:grob-set-property! grob (car x) (cdr x))) tweaks))))) customScripts = #(define-music-function (settings) (list?) #{ \override Script.before-line-breaking = #(custom-script-tweaks settings) #}) revertCustomScripts = \revert Script.before-line-breaking % Example % Predefine two sets of desired tweaks. #(define my-settings-1 '( (accent . ((font-size . 0) (color . (1 0 0)))) (segno . ((font-size . 0) (color . (1 0 0)))) (staccato . ((color . (1 0 0)) (padding . 0.5))) (staccatissimo . ((padding . 1) (color . (1 0 0)))) (tenuto . ((color . (1 0 0)) (rotation . (45 0 0)) (padding . 2) (font-size . 10))) )) #(define my-settings-2 '( (accent . ((font-size . 4) (color . (0 1 0)) (padding . 1.5))) (coda . ((color . (0 1 0)) (padding . 1))) (staccato . ((color . (0 1 0)))) (staccatissimo . ((padding . 2) (color . (0 1 0)))) (tenuto . ((color . (0 1 0)) (font-size . 10))) )) music = { f1-> | f\segno | f-. | f-! | f-- | f--\coda | f-!\fermata | } block = { \music \break \revertCustomScripts \music } \new Staff << \new Voice \with { \customScripts #my-settings-1 } \relative c''{ \voiceOne \block } \new Voice \with { \customScripts #my-settings-2 } \relative c' { \voiceTwo \block } >>
| [ << Tweaks and overrides ] | [Top][Contents] | [ Workaround >> ] |
| [ < Imbrications de regroupements de portées ] | [ Up: Tweaks and overrides ] | [ Affichage du numéro de répétition en pourcent > ] |