lilypond-user
[Top][All Lists]
Advanced

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

Re: Size of the arpeggio's arrow


From: Thomas Morley
Subject: Re: Size of the arpeggio's arrow
Date: Thu, 5 Dec 2019 20:56:15 +0100

Am Do., 5. Dez. 2019 um 20:46 Uhr schrieb Thomas Morley
<address@hidden>:
>
> Am Do., 5. Dez. 2019 um 20:01 Uhr schrieb Thomas Morley
> <address@hidden>:
> >
> > Am Do., 5. Dez. 2019 um 19:02 Uhr schrieb Thomas Morley
> > <address@hidden>:
> > >
> > > Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
> > > <address@hidden>:
> > > >
> > > > Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <address@hidden>:
> > > > >
> > > > >
> > > > > Hi Thomas.
> > > > > Yes, I'm interested. I could not find any snippet for that, nor a 
> > > > > corresponding property for "Arpeggio" in the "Lilypond Internals 
> > > > > Reference"
> > > > > Thanks.
> > > > >
> > > > > Il giovedì 5 dicembre 2019, 16:22:12 GMT, Thomas Morley 
> > > > > <address@hidden> ha scritto:
> > > > >
> > > > >
> > > > > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <address@hidden>:
> > > > >
> > > > > >
> > > > > > (I re-post this because it seems that mails from Yahoo services, 
> > > > > > like some of my previous posts, are filtered as spam)
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > how can I modify the size of the arrow of an \arpeggioArrowUp/Down 
> > > > > > object?
> > > > > >
> > > > > > Thanks
> > > > >
> > > > > >
> > > > >
> > > > > There is no builtin method to do so.
> > > > > You could create your own stencil, though.
> > > > >
> > > > > Interested in learning howto?
> > > > >
> > > > >
> > > > > Cheers,
> > > > >   Harm
> > > > >
> > > > >
> > > >
> > > > Ok :)
> > > > So what do we want?
> > > > While applying \arpeggioArrowUp we want the usual arpeggio, but the
> > > > added arrow-head should be sized as we want.
> > > >
> > > > Alas, as soon as we set \arpeggioArrowUp the default is there.
> > > > Mmhh, what exactly does \arpeggioArrowUp?
> > > > Looking into property-init.ly (found by some search-functions of your
> > > > editor or some grepping):
> > > >
> > > > arpeggioArrowUp = {
> > > >   \revert Arpeggio.stencil
> > > >   \revert Arpeggio.X-extent
> > > >   \override Arpeggio.arpeggio-direction = #UP
> > > > }
> > > >
> > > > Interesting is arpeggio-direction, looks like it triggers the arrowed 
> > > > arpeggio.
> > > > Let's proof:
> > > >
> > > > {
> > > >   \arpeggioArrowUp
> > > >   R1
> > > >   \override Arpeggio.arpeggio-direction = #'()
> > > >   <b d' f' b'>\arpeggio
> > > > }
> > > >
> > > > And indeed the arrow-head is gone.
> > > >
> > > > Now we can recreate the _default_-stencil explicitely, using the
> > > > default-stencil, found in IR.
> > > > I.e. the procedure ly:arpeggio::print
> > > > NB, although we've set \arpeggioArrowUp
> > > >
> > > > {
> > > >   \arpeggioArrowUp
> > > >   R1
> > > >   \override Arpeggio.arpeggio-direction = #'()
> > > >   \override Arpeggio.stencil =
> > > >   #(lambda (grob)
> > > >      (ly:arpeggio::print grob))
> > > >   <b d' f' b'>\arpeggio
> > > > }
> > > >
> > > > Let us put the arpeggio-direction into the stencil-override for 
> > > > conveniance:
> > > >
> > > > {
> > > >   \arpeggioArrowUp
> > > >   R1
> > > >   \override Arpeggio.stencil =
> > > >   #(lambda (grob)
> > > >      (ly:grob-set-property! grob 'arpeggio-direction '())
> > > >      (ly:arpeggio::print grob))
> > > >   <b d' f' b'>\arpeggio
> > > > }
> > > >
> > > > Now we only need to add a suitable arrowhead to the stencil and are 
> > > > done.
> > > >
> > > >
> > > > So I need a little break, I'm cooking right now ;)
> > > >
> > > >
> > > > Cheers,
> > > >   Harm
> > >
> > > Now let's care about the arrow-head.
> > > Probably you noticed the arrow-heads in A.8 "The Emmentaler font" of NR:
> > > "scripts.arpeggio.arrow.1" and "scripts.arpeggio.arrow.M1"
> > >
> > > Likely it's best to select the arrow-head depending on the direction, with
> > >
> > >   (format #f
> > >     "scripts.arpeggio.arrow.~a1"
> > >     (if (negative? arp-dir)
> > >         "M"
> > >         ""))
> > >
> > > where arp-dir is the arpeggio-direction, i.e. for no we disregard what
> > > I said earlier.
> > >
> > > Now we have the glyph and we need to look it up in the font.
> > > Ok, so we need to get the font.
> > >
> > > Maybe you stumbled across ly:grob-default-font already, with this one
> > > we get the font.
> > > Now we can lookup, using ly:font-get-glyph.
> > >
> > > ly:grob-default-font and ly:font-get-glyph can be found in IR.
> > > To learn how to use them you will need to look throuw our source-code, 
> > > though.
> > > I don't know much examples for it.
> > >
> > > Disregarding the arpeggio, only putting out the arrow-head it makes for:
> > >
> > >
> > > myArpeggio =
> > >   \override Arpeggio.stencil =
> > >   #(lambda (grob)
> > >     (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction))
> > >            (arrow-glyph
> > >              (format #f
> > >                "scripts.arpeggio.arrow.~a1"
> > >                (if (negative? arp-dir)
> > >                    "M"
> > >                    ""))))
> > >
> > >      (ly:font-get-glyph (ly:grob-default-font grob) arrow-glyph)))
> > >
> > > {
> > >   \arpeggioArrowUp
> > >   \myArpeggio
> > >   <b d' f' b'>\arpeggio
> > >
> > >
> > >   \arpeggioArrowDown
> > >   \myArpeggio
> > >   <b d' f' b'>\arpeggio
> > > }
> > >
> > > Now we've created single arrow-heads depending on the direction.
> > >
> > >
> > > TODO:
> > > Adjust size of the arrow-heads
> > > Move them to the place where they should be
> > > Combine it with the usual trill-like arpeggio-line
> > >
> > >
> > > Laters,
> > >   Harm
> >
> > Next steps: move the arrow-heads correctly/combine with arpeggio-line
> >
> > For better debugging I colored the arrows red.
> > To move them correctly we need the y-ext of the arpeggio-stencil.
> > If arppeggio-direction is up we can use the cdr of the arpeggio-stencil.
> > But if arppeggio-direction is down (car stil-y-ext) is not sufficient,
> > we need to take the y-ext of the arrow into account as well.
> > Move is done with ly:stencil-translate-axis.
> > Finally simply add them with ly:stencil-add.
> >
> > myArpeggio =
> >   \override Arpeggio.stencil =
> >   #(lambda (grob)
> >     (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction))
> >            (arrow-glyph
> >              (format #f
> >                "scripts.arpeggio.arrow.~a1"
> >                (if (negative? arp-dir)
> >                    "M"
> >                    "")))
> >            (font (ly:grob-default-font grob))
> >            (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
> >            (red-arrow (stencil-with-color arrow-head-stil red))
> >            (red-arrow-y-ext (ly:stencil-extent red-arrow Y)))
> >
> >       (ly:grob-set-property! grob 'arpeggio-direction '())
> >
> >       (let* ((stil (ly:arpeggio::print grob))
> >              (stil-y-ext (ly:stencil-extent stil Y)))
> >
> >         (ly:stencil-add
> >           (ly:stencil-translate-axis
> >             red-arrow
> >             (if (negative? arp-dir)
> >                 (- (car stil-y-ext) (interval-length red-arrow-y-ext))
> >                 (cdr stil-y-ext))
> >             Y)
> >           stil))))
> >
> > {
> >   \arpeggioArrowUp
> >   \myArpeggio
> >   <b d' f' b'>\arpeggio
> >
> >
> >   \arpeggioArrowDown
> >   \myArpeggio
> >   <b d' f' b'>\arpeggio
> > }
> >
> > TODO Resize the arrow-head
> >
> >
> > Cheers,
> >   Harm
>
> In my last mail I actually sort of recreated the arrowed arpeggio-stencil.
> This is fine, because no we can start manipulating it.
> Let's try to scale up the arrows a bit, using ly:stencil-scale, see IR.
>
>
> myArpeggio =
>   \override Arpeggio.stencil =
>   #(lambda (grob)
>     (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction))
>            (arrow-glyph
>              (format #f
>                "scripts.arpeggio.arrow.~a1"
>                (if (negative? arp-dir)
>                    "M"
>                    "")))
>            (font (ly:grob-default-font grob))
>            (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
>            (red-arrow
>              (ly:stencil-scale
>                (stencil-with-color arrow-head-stil red)
>                1.5 1.5))
>            (red-arrow-y-ext (ly:stencil-extent red-arrow Y)))
>
>       (ly:grob-set-property! grob 'arpeggio-direction '())
>
>       (let* ((stil (ly:arpeggio::print grob))
>              (stil-y-ext (ly:stencil-extent stil Y))
>              (stil-x-ext (ly:stencil-extent stil X)))
>         (ly:stencil-add
>           (ly:stencil-translate-axis
>             red-arrow
>             (if (negative? arp-dir)
>                 (- (car stil-y-ext) (interval-length red-arrow-y-ext))
>                 (cdr stil-y-ext))
>             Y)
>           stil))))
>
> {
>   \arpeggioArrowUp
>   \myArpeggio
>   <b d' f' b'>\arpeggio
>
>
>   \arpeggioArrowDown
>   \myArpeggio
>   <b d' f' b'>\arpeggio
> }
>
>
> Though, now the arrow-head is a little off regarding x-axis.
>
> We need to compensate, best to move him back where he belongs by half
> the difference of arpeggio and arrow-stils widths.
> Thus we switch from ly:stencil-translate-axis to ly:stencil-translate
> expecting a pair for x/y.
>
> Makes for:
>
> myArpeggio =
>   \override Arpeggio.stencil =
>   #(lambda (grob)
>     (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction))
>            (arrow-glyph
>              (format #f
>                "scripts.arpeggio.arrow.~a1"
>                (if (negative? arp-dir)
>                    "M"
>                    "")))
>            (font (ly:grob-default-font grob))
>            (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
>            (red-arrow
>              (ly:stencil-scale (stencil-with-color arrow-head-stil
> red) 1.5 1.5))
>            (red-arrow-y-ext (ly:stencil-extent red-arrow Y))
>            (red-arrow-x-ext (ly:stencil-extent red-arrow X)))
>
>       (ly:grob-set-property! grob 'arpeggio-direction '())
>
>       (let* ((stil (ly:arpeggio::print grob))
>              (stil-y-ext (ly:stencil-extent stil Y))
>              (stil-x-ext (ly:stencil-extent stil X)))
>         (ly:stencil-add
>           (ly:stencil-translate
>             red-arrow
>             (if (negative? arp-dir)
>                 (cons
>                  (/
>                   (- (interval-length stil-x-ext)
>                      (interval-length red-arrow-x-ext)
>                      )
>                   2)
>                   (- (car stil-y-ext) (interval-length red-arrow-y-ext)))
>                 (cons
>                  (/
>                   (- (interval-length stil-x-ext)
>                      (interval-length red-arrow-x-ext)
>                      )
>                   2)
>                   (cdr stil-y-ext))))
>           stil))))
>
> {
>   \arpeggioArrowUp
>   \myArpeggio
>   <b d' f' b'>\arpeggio
>
>
>   \arpeggioArrowDown
>   \myArpeggio
>   <b d' f' b'>\arpeggio
> }
>
> TODO
> - remove the color
> - probably transform the override into a music-function, then the now 
> hardcoded
>   scaling value is more conveniant settable.

I forgot, sometimes the arpeggio is to tall now.
Probably add an override for 'positions or something like
\offset positions #'(1 . 0) Arpeggio
or
tackle 'positions directly in myArpeggio

>
> Shouldn't be hard from here, please ask if something isn't clear.
>
> Ofcourse you need to test all with real world examples. Some bugs may
> raise their head...
>
> NB if the scaling value is too high, then the output will be always poor.
> If you really need a huge arrow-head, we would need to construct it
> from scratch, not looking into the font.
>
>
> Tutorial closed for now lol
>
> Best,
>   Harm



reply via email to

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