-
Notifications
You must be signed in to change notification settings - Fork 0
Variable slur thickness
Sharon Rosner edited this page Mar 11, 2016
·
5 revisions
The default look of slurs in lilypond is not ideal, because their thickness is constant. Short slurs will have the same thickness (in the middle) as very long slurs, which leads to either short slurs that are too thick or long slurs that are too thin.
The following code adjust the thickness of each slur in proportion to its length:
#(define (variable-slur-thickness min-l max-l min-t max-t) (lambda (grob)
(let* ((cpf (if (grob::has-interface grob 'tie-interface)
ly:tie::calc-control-points
ly:slur::calc-control-points))
(cpt (cpf grob))
(cp0 (car cpt)) (cp3 (cadddr cpt))
(dx (- (car cp3) (car cp0)))
(dy (- (cdr cp3) (cdr cp0)))
(len (magnitude (make-rectangular dx dy)))
(thickness
(cond ((< len min-l) min-t)
((> len max-l) max-t)
(else (+ min-t (* (- len min-l)
(/ (- max-t min-t) (- max-l min-l))))))))
thickness)))
\layout {
\override Slur.thickness = #(variable-slur-thickness 3 10 1.4 2.7)
% works for ties, too!
\override Tie.thickness = #(variable-slur-thickness 3 10 1.4 2.7)
}