[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tuplet bracket and cross staff
From: |
David Nalesnik |
Subject: |
Re: Tuplet bracket and cross staff |
Date: |
Sun, 26 Jun 2016 07:24:20 -0500 |
Hi Harm,
On Sun, Jun 26, 2016 at 3:53 AM, Thomas Morley <address@hidden> wrote:
> 2016-06-26 5:00 GMT+02:00 Andrew Bernard <address@hidden>:
>> Hi Matteo,
>>
>> I have a tuplet angle function that somebody (I cannot recall who)
>> sent me some time ago. I use it heavily and extensively and I can say
>> it has been tested by me to the limit - it works well.
>>
>> Using this code you just say \tupletAngles 1 0 or similar and that's
>> all you need. Put it is a file tuplet-angles.ily and include it. Using
>> \tupletAngles 0 0 is very handy for straigthening up tuplets when you
>> don't want lilypond to angle them.
>>
>> Here it is. [Surprised this is not more well known.]
>>
>> Andrew
>
> Looking in the archives:
> http://lilypond.1069038.n5.nabble.com/angle-of-a-tuplet-bracket-td55019.html#a55023
> :)
>
A very useful function!
It occurs to me that you could override 'positions directly without
consulting the stencil, instead of as a side-effect:
%% ===========================================
tupletAngles =
#(define-music-function (y-off angl)(number? number?)
"
y-off a (possible) offset in Y-direction
angl is supposed to be the angle of the TupletBracket in degrees,
"
#{
\once\override TupletBracket #'positions =
#(lambda (grob)
(let* ((pos (ly:tuplet-bracket::calc-positions grob))
(y-length (interval-length pos))
(x-length (interval-length
(ly:tuplet-bracket::calc-x-positions grob)))
(alpha (degrees->radians angl))
(dir (ly:grob-property grob 'direction))
(new-start (+ (if (= dir 1)
(max (car pos)(cdr pos))
(min (car pos)(cdr pos)))
y-off))
(new-y (* x-length (tan alpha))))
(cons new-start (+ new-start new-y))))
#})
horizontalTuplets =
\override TupletBracket #'positions =
#(lambda (grob)
(let* ((pos (ly:tuplet-bracket::calc-positions grob))
(dir (ly:grob-property grob 'direction))
(new-pos (if (= dir 1)
(max (car pos)(cdr pos))
(min (car pos)(cdr pos)))))
(cons new-pos new-pos)))
%% ===========================================
(For newer versions, maybe it would be helpful to work in the
grob-transformer function?)
--DN