lilypond-user
[Top][All Lists]
Advanced

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

Re: Spannerize glyphs, markups etc. ?


From: David Nalesnik
Subject: Re: Spannerize glyphs, markups etc. ?
Date: Thu, 4 Feb 2021 12:12:11 -0600

Hi Dimitris,

On Thu, Feb 4, 2021 at 10:36 AM Dimitris Marinakis <dtsmarin02@gmail.com> wrote:
>
> Thank you. This certainly works for simple scenarios.
>
> Here is my incomplete take. I just need to find out how to automatically 
> change the number that repeats the stencil based on the spanner length.
> Sorry if this doesn't make sense. I just started learning bit by bit how to 
> make things work in Scheme.
> trillsymb = \markup {
> \concat
> {
> \scale #'(1.5 . 1)
> \musicglyph #"scripts.trillelement"
> \musicglyph #"scripts.turn"
>  }
> }
>  #(define (alterspan grob)
>    (if (ly:stencil? (ly:line-spanner::print grob))
>      (let* ((stencil (ly:line-spanner::print grob))
>             (dot (ly:font-get-glyph (ly:grob-default-font grob) 
> "scripts.turn"))
>          (X-ext (ly:stencil-extent stencil X))
>             (Y-ext (ly:stencil-extent stencil Y))
>             (width 0.1)
>             (len (interval-length X-ext)))
>        (ly:stencil-translate
>          (grob-interpret-markup grob
>            (markup
> ; really crude method but I think it can work just fine
> ; spanner length / stencil extend ??
>        (#:pattern (inexact->exact (round (* len
>   ;need a way to automatically change this number based on the stencil 
> dimensions
>                                            0.3 ))) X 0
>       (markup #:scale (cons 1 1) trillsymb)
>             )
> )
>            )
>           (cons (interval-start X-ext) (interval-start Y-ext))))
>      #f))
>
>
>
>
> {
> \override Score.TextSpanner.stencil = #alterspan
> <c' g'>4\startTextSpan
> <c' g'>4
> <c' g'>4
> c'4
> d'
> e'
> f'
> g'\stopTextSpan
> }

Here's a slight rewrite of your code which calculates the number of
pattern statements automatically.

One problem is that the right edge of the spanner will sometimes stop
short of the right end of the base spanner.  This could be improved by
adding dot, turn, dot, turn, dot, etc.--allowing for the possibility
of ending with a dot--rather than building the spanner from
indivisible dot-turn units.

(Ultimately I imagine you will want provision for line breaks too.  A
hassle, but doable.)

Hope this helps,
David

Attachment: spannerize.ly
Description: Text Data


reply via email to

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