lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable slur thickness


From: Thomas Morley
Subject: Re: Variable slur thickness
Date: Thu, 10 Mar 2016 22:55:12 +0100

2016-03-10 17:14 GMT+01:00 tisimst <address@hidden>:
>
> On Thu, Mar 10, 2016 at 9:04 AM, Malte Meyn-3 [via Lilypond] <[hidden
> email]> wrote:
>>
>>
>>
>> Am 10.03.2016 um 16:56 schrieb tisimst:
>> > Submitted to LSR: http://lsr.di.unimi.it/LSR/Item?id=1028
>> >
>>
>> The header of the third score isn’t correct: Thickness goes from 1.2 to
>> 2.7, not 1.4 to 2.7.
>
>
> (facepalm) Thanks. Corrected.
>
> - Abraham



Hi Abraham,

I had a look.
Pretty nice one, some nitpicks, though.

How about:

#(define (variable-slur-thickness min-l max-l min-t max-t)
  (lambda (grob)
    (let* ((cpt (ly:grob-property grob 'control-points))
           (cp0 (car cpt))
           (cp3 (cadddr cpt))
;; dx/dy is clearer I think
           (dx (- (car cp3) (car cp0)))
           (dy (- (cdr cp3) (cdr cp0)))
;; avoids Pythagoras
           (len (magnitude (make-rectangular dx dy)))
;; avoids nested if
           (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))))))))
      (ly:grob-set-property! grob 'thickness thickness))))

Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]