[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme: get current beam-thickness
From: |
David Kastrup |
Subject: |
Re: Scheme: get current beam-thickness |
Date: |
Sat, 25 Jan 2020 20:40:51 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Aaron Hill <address@hidden> writes:
> 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
> }
> %%%%
>
> I am unaware of any simpler approach, as it is my understanding that
> grobs do not persist the entire context within which they were
> created.
How would they then make it to the page? Suicided grobs have their
properties deleted prematurely, but those are not the rule.
> Mind you, I would love to be shown that I am incorrect.
This is Scheme anyway. In general, objects persist as long as you are
able to reference them.
--
David Kastrup
- Scheme: get current beam-thickness, David Stephen Grant, 2020/01/25
- Re: Scheme: get current beam-thickness, Thomas Morley, 2020/01/25
- Re: Scheme: get current beam-thickness, Aaron Hill, 2020/01/25
- Re: Scheme: get current beam-thickness,
David Kastrup <=
- 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