[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tie with slash (caesura) on the curve
From: |
Jean Abou Samra |
Subject: |
Re: Tie with slash (caesura) on the curve |
Date: |
Thu, 10 Nov 2022 11:23:19 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 |
Le 10/11/2022 à 04:31, Pierre Perol-Schneider a écrit :
How about:
\version "2.22.0"
oldTie = \once \override Tie.after-line-breaking =
#(lambda (grob)
(let*
((stencil (ly:tie::print grob))
(dir (ly:grob-property grob 'direction))
(markup-stencil
(grob-interpret-markup grob
(markup #:scale (cons .8 0.5)
(#:musicglyph "scripts.caesura.straight"))))
(shift (- (interval-center (ly:stencil-extent stencil X))
(interval-center (ly:stencil-extent markup-stencil
X))))
(new-stencil
(ly:stencil-combine-at-edge stencil
Y dir
(ly:stencil-translate-axis markup-stencil shift X)
-.63)))
(ly:grob-set-property! grob 'stencil new-stencil)))
{
\clef"G_8"
f'16 16
\oldTie
8~ 16 16 8
}
Hi Pierre,
This is nice! Just a thought: why use after-line-breaking
here? This is the sort of thing that can cause mysterious bugs
if something else reads the stencil property before your
after-line-breaking callback is executed. In general, it's
good practice to stick with normal callbacks in most cases,
and only use after-line-breaking if you really need it.
Also, you can use grob-transformer to get the default value.
This way, if the default changes in a future version, the code
will still work. (grob-transformer is documented here:
https://lilypond.org/doc/v2.22/Documentation/extending/callback-functions)
So, I'd do:
\version "2.22.2"
oldTie =
\once \override Tie.stencil =
#(grob-transformer
'stencil
(lambda (grob default-stencil)
(let* ((dir (ly:grob-property grob 'direction))
(caesura-stencil
(grob-interpret-markup grob
(markup #:scale (cons .8 0.5)
(#:musicglyph "scripts.caesura.straight"))))
(shift (- (interval-center (ly:stencil-extent
default-stencil X))
(interval-center (ly:stencil-extent
caesura-stencil X)))))
(ly:stencil-combine-at-edge
default-stencil
Y dir
(ly:stencil-translate-axis caesura-stencil shift X)
-.63))))
{
\clef"G_8"
f'16 16
\oldTie
8~ 16 16 8
}
Best,
Jean
OpenPGP_signature
Description: OpenPGP digital signature