[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme: get current beam-thickness
From: |
Thomas Morley |
Subject: |
Re: Scheme: get current beam-thickness |
Date: |
Sun, 26 Jan 2020 13:11:04 +0100 |
Am So., 26. Jan. 2020 um 12:41 Uhr schrieb David Kastrup <address@hidden>:
>
> Thomas Morley <address@hidden> writes:
>
> > Am Sa., 25. Jan. 2020 um 20:31 Uhr schrieb Aaron Hill
> > <address@hidden>:
> >>
> >> On 2020-01-25 10:39 am, David Stephen Grant wrote:
> >> > I'm trying to create a custom flag stencil, and would like to get the
> >> > current _beam_ thickness. As a first step, in the following example I
> >> > would
> >> > expect 0.5, then 1, to be printed to the console. Is there a way of
> >> > doing
> >> > this?
> >>
> >> With a little bit of encouragement, yes:
> >>
> >> %%%%
> >> \version "2.19.83"
> >>
> >> BeamThicknessToFlag_engraver = #(lambda (...)
> >> `((acknowledgers
> >> (flag-interface . ,(lambda (engraver grob source-engraver)
> >> (ly:grob-set-property! grob 'beam-thickness
> >> (ly:assoc-get 'beam-thickness
> >> (ly:context-grob-definition
> >> (ly:translator-context engraver)
> >> 'Beam))))))))
> >>
> >> customFlag = #(lambda (grob)
> >> (let ((bt (ly:grob-property grob 'beam-thickness)))
> >> (grob-interpret-markup grob #{ \markup #(number->string bt) #})))
> >>
> >> \new Voice
> >> \with { \consists \BeamThicknessToFlag_engraver }
> >> {
> >> \override Flag.stencil = \customFlag
> >>
> >> c'8 r8
> >>
> >> \override Beam.beam-thickness = #0.5
> >> c'8 r8
> >>
> >> \override Beam.beam-thickness = #1.0
> >> c'8 r8
> >>
> >> \revert Beam.beam-thickness
> >> c'8 r8
> >> }
> >> %%%%
> >
> > Hi Aaron,
> >
> > I stand corrected, it is possible.
> > Alas, going for a custom-engraver feels overdone, if not really
> > needed. Thus I asked about the final goal.
> >
> > Even at the risk being regarded as a nitpicker and also being aware we
> > have similar codings (wrt to juggling grob-properties) in our docs,
> > the code will return several programming errors if compiled with
> > -dcheck-internal-types.
>
> I have some incomplete work in branches that would significantly speed
> up property accesses but would not support undeclared properties.
>
> Not that we have a good interface for adding them yet...
Furthermore, ly:add-interface obviously creates a _new_ interface, not
adding something to a probably preexistent one, as I naively assumed.
So below should better read:
#(ly:add-interface
'flag-interface
"A flag"
'(beam-thickness
glyph-name
stroke-style
style))
>
> > To cure, one could add:
> > #(ly:add-interface
> > 'flag-interface
> > "A flag"
> > '(beam-thickness))
>
> --
> David Kastrup
Cheers,
Harm
- Re: Scheme: get current beam-thickness, (continued)
- Re: Scheme: get current beam-thickness, Aaron Hill, 2020/01/25
- Re: Scheme: get current beam-thickness, David Kastrup, 2020/01/25
- Re: Scheme: get current beam-thickness, David Stephen Grant, 2020/01/25
- Re: Scheme: get current beam-thickness, Aaron Hill, 2020/01/25
- Re: Scheme: get current beam-thickness, David Kastrup, 2020/01/25
- Re: Scheme: get current beam-thickness, Aaron Hill, 2020/01/25
- Re: Scheme: get current beam-thickness, David Kastrup, 2020/01/25
- Re: Scheme: get current beam-thickness, Aaron Hill, 2020/01/25
Re: Scheme: get current beam-thickness, Thomas Morley, 2020/01/26