Thank you for this Aaron!
Cheers,
Pierre
Le jeu. 17 oct. 2019 à 06:42, Aaron Hill <[email protected]> a
écrit :
> On 2019-10-16 7:00 pm, Graham King wrote:
> > \version "2.19.82"
> > {
> > \once \override Staff.TimeSignature #'stencil =
> > #(lambda (grob)
> > (grob-interpret-markup
> > grob
> > #{ \markup
> > \override #'(baseline-skip . 1)
> > \center-column {
> > \musicglyph "four"
> > \musicglyph "noteheads.sM1" } #}))
> > \time 8/1
> > c'\breve c' c' c'
> > }
>
> If you find yourself doing this type of stencil \override on a regular
> basis, you could wrap it up in a more general-purpose helper similar to
> the following:
>
> %%%%
> \version "2.19.83"
>
> replace-stencil = #(define-music-function (grob text) (grob-list?
> markup?)
> (define (stencil grob) (grob-interpret-markup grob text))
> #{ \override $grob . stencil = $stencil #})
>
> {
> \once \replace-stencil Staff.TimeSignature
> \markup \override #'(baseline-skip . 1)
> \center-column { \musicglyph "four" \musicglyph "noteheads.sM1" }
> \time 8/1 c'\breve c' c' c'
> }
> %%%%
>
> Putting together the function above got me thinking about and working on
> a version that overlays \markup on an existing stencil instead of
> replacing it:
>
> %%%%
> \version "2.19.83"
>
> overlay-stencil = #(define-music-function (grob align text)
> (grob-list? (number-pair? '(0 . 0)) markup?)
> (define stencil (grob-transformer 'stencil (lambda (grob orig)
> (let ((x (interval-index (ly:stencil-extent orig X) (car align)))
> (y (interval-index (ly:stencil-extent orig Y) (cdr align)))
> (new (grob-interpret-markup grob text)))
> (ly:stencil-add orig (ly:stencil-translate new (cons x y)))))))
> #{ \override $grob . stencil = $stencil #})
>
> red-x = \markup \with-dimensions-from \null
> \vcenter \center-align \with-color #red "X"
>
> {
> \overlay-stencil Staff.Clef #'(-1 . 1) "Clef"
> b'8 c''
> \temporary \overlay-stencil NoteHead \red-x
> g' a'
> \revert NoteHead.stencil
> b'2
> }
> %%%%
>
> Not sure how useful these would be in practice, but the resulting syntax
> might be preferable for some folks.
>
>
> -- Aaron Hill_______________________________________________
> lilypond-user mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user