| [ << Staff notation ] | [Top][Contents] | [ Editorial annotations >> ] |
| [ < Extender glissandos sobre repeticiones ] | [ Up: Staff notation ] | [ Forcing measure width to adapt to a metronome mark’s width > ] |
Ligaduras planas
Este fragmento de código aporta una función flared-tie para
trazar una ligadura formada por líneas rectas. Su objetivo es
sustituir a la función predeterminada de trazado de la ligadura
(esto es, servir como un argumento sustitutorio para la propiedad
stencil del objeto gráfico Tie).
El argumento de flared-tie es una lista de pare de
coordenadas que especifican puntos adicionales entre el primero y
el último para abarcar todas las líneas de la ligadura. Los
puntos primero y último son idénticos a los puntos de inicio y
final de la ligadura, respectivamente. Los valores de las
coordenadas X e Y son múltiplos de la longitud y la
altura del rectángulo circundante (teniendo también en cuenta la
dirección de la ligadura); por tanto, el primer punto tiene las
coordenadas (0,0), y el último (1,0).
La función flare-tie define una forma abreviada de
especificar una ligadura plana. Es posible efectuar un trucaje
adicional de la forma mediante la sobreescritura de
Tie.details.height-limit o con la función \shape.
También es posible cambiar la definición personalizada sobre la marcha.
#(define ((flared-tie coords) grob) (define (pair-to-list pair) (list (car pair) (cdr pair))) (define (normalize-coords goods x y dir) (map (lambda (coord) (cons (* x (car coord)) (* y dir (cdr coord)))) goods)) (define (my-c-p-s points thick) (make-connected-path-stencil points thick 1.0 1.0 #f #f)) ;; Calling `ly:tie::print` and assigning its return value to a ;; variable in this outer `let` triggers LilyPond to position the ;; tie, allowing us to extract its extents. We only proceed, ;; however, if the tie doesn't get discarded (for whatever reason). (let ((sten (ly:tie::print grob))) (if (grob::is-live? grob) (let* ((layout (ly:grob-layout grob)) (line-thickness (ly:output-def-lookup layout 'line-thickness)) (thickness (ly:grob-property grob 'thickness 0.1)) (used-thick (* line-thickness thickness)) (dir (ly:grob-property grob 'direction)) (xex (ly:stencil-extent sten X)) (yex (ly:stencil-extent sten Y)) (lenx (interval-length xex)) (leny (interval-length yex)) (xtrans (car xex)) (ytrans (if (> dir 0)(car yex) (cdr yex))) ;; Add last point. (coord-list (append coords '((1.0 . 0.0)))) (uplist (map pair-to-list (normalize-coords coord-list lenx (* leny 2) dir)))) (ly:stencil-translate (my-c-p-s uplist used-thick) (cons xtrans ytrans))) '()))) % Define a default tie shape consisting of three straight lines. #(define flare-tie (flared-tie '((0.1 . 0.3) (0.9 . 0.3)))) \relative c' { a4~ a \once \override Tie.stencil = #flare-tie a4~ a \break <a c e a c e a c e>~ q \once \override Tie.stencil = #flare-tie q~ q\break <>^\markup \small \typewriter "height-limit = 14" \override Tie.details.height-limit = 14 a'4~ a \once \override Tie.stencil = #flare-tie a4~ a \break <>^\markup \small \typewriter "height-limit = 0.5" \override Tie.details.height-limit = 0.5 a4~ a \once \override Tie.stencil = #flare-tie a4~ a \break \revert Tie.details.height-limit <>^\markup \small \typewriter "\shape #'((0 . 0) (0 . -1) (0 . -1) (0 . 0))" \shape #'((0 . 0) (0 . -1) (0 . -1) (0 . 0)) Tie a4~ a \once \override Tie.stencil = #flare-tie \shape #'((0 . 0) (0 . -1) (0 . -1) (0 . 0)) Tie a4~ a \break <>^\markup \small \typewriter "#(flared-tie '((0.2 . 2) (0.5 . -3) (0.8 . 1))" \once \override Tie.stencil = #(flared-tie '((0.2 . 2) (0.5 . -3) (0.8 . 1))) a4~ a <>_\markup \small \typewriter "#(flared-tie '((0.5 . 2)))" \once \override Tie.stencil = #(flared-tie '((0.5 . 2))) a'4~ a }
| [ << Staff notation ] | [Top][Contents] | [ Editorial annotations >> ] |
| [ < Extender glissandos sobre repeticiones ] | [ Up: Staff notation ] | [ Forcing measure width to adapt to a metronome mark’s width > ] |