[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: adjusting vertical positions of start and end of tie
From: |
Thomas Morley |
Subject: |
Re: adjusting vertical positions of start and end of tie |
Date: |
Fri, 7 Aug 2020 01:51:28 +0200 |
Am Fr., 7. Aug. 2020 um 00:34 Uhr schrieb Werner LEMBERG <wl@gnu.org>:
>
>
> > Look at this example
> >
> >
> > \relative c' {
> > \clef "alto" d'2 \tweak positions #'(8 . 4) ~
> > \clef "treble" d2
> > }
> >
> > The `\tweak positions` doesn't work – which is kind-of expected.
> > However, for this very situation it would be nice if I could change
> > the start and end position of the slur manually.
>
> Of course, it would be even better if LilyPond could handle this
> situation automatically :-)
>
>
> Werner
Hi Werner,
you could translate the control-points _iff_ left/right-bound's
staff-positions are not equal.
Below a proof-of-concept. Though it transforms linear, this is the
wrong math here, thus the Tie looks not very well, too late to dive
into Bezier-things...:
Anyway, here's the code:
\relative c' {
\override Tie.after-line-breaking =
#(lambda (grob)
(let* ((left-bound (ly:spanner-bound grob LEFT))
(left-x-pos (ly:grob-property left-bound 'staff-position))
(right-bound (ly:spanner-bound grob RIGHT))
(right-x-pos (ly:grob-property right-bound 'staff-position))
(cps (ly:grob-property grob 'control-points))
(first-cp (car cps))
(last-cp (last cps))
(x1 (car first-cp))
(x2 (car last-cp))
(y1 (cdr first-cp))
(y2 right-x-pos)
(gradient (/ (- y2 y1) (- x2 x1)))
(y-off (/ (- (* x1 y2) (* x2 y1)) (- x1 x2)))
(func (lambda (x) (- y1 (+ (* gradient x) y-off)))))
(if (not (eqv? left-x-pos right-x-pos))
(ly:grob-set-property! grob 'control-points
(map
(lambda (cp)
(cons (car cp) (- (cdr cp) (func (car cp)))))
cps)))))
\clef "alto" d'2~
\clef "treble" d2
d~ d
}
Maybe a starting point for an automagic solution.
Cheers,
Harm
Re: adjusting vertical positions of start and end of tie, David Nalesnik, 2020/08/06