lilypond-user
[Top][All Lists]
Advanced

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

Re: Reading a property


From: David Nalesnik
Subject: Re: Reading a property
Date: Wed, 1 Apr 2015 12:34:40 -0500

Sorry, hit the wrong button...

On Wed, Apr 1, 2015 at 9:13 AM, Klaus Blum <address@hidden> wrote:
Dear LilyPond fellows,

how can I read a property?
For example, after having applied
\override HorizontalBracket.line-thickness = #0.5
is there an easy way to access that value?

I know that it will work like this:

colorSpan =
#(define-music-function (parser location y-lower y-upper color)
     (number? number? color?)
    #{
      \once\override HorizontalBracket.stencil =
        $(lambda (grob)
          (let* (
                  (thick (ly:grob-property grob 'line-thickness 1))
            ... do other stuff ...
            (ly:make-stencil (list 'color color
              (ly:stencil-expr (ly:round-filled-box X-ext Y-ext 0))
              X-ext Y-ext))))
    #})

But that only works "inside" this replacement function. Am I missing the
obvious?


I don't think you're missing the obvious! 

Default values are stored in an alist 'all-grob-descriptions' defined in scm/define-grobs.scm.  So it wouldn't be difficult to access _default_ settings.  However, if you want to get at a changed value, I can't see any way to do it without an actual grob as an argument.

Well, you could parse the Scheme music _expression_, but that doesn't sound fun, and I don't know that that will do you any good.  You can see the result of the override in the log output:

%%%%%%%%%%%%%
\version "2.19.17"

\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
  }
}

\displayMusic {
  \override HorizontalBracket.line-thickness = 2
  c\startGroup d\stopGroup
}
%%%%%%%%%%%%%%

Why exactly are you trying to get at the changed value?  Maybe I or someone could suggest a solution knowing what you are trying to accomplish.



I'm trying to expand what has been started with snippet 960:
http://lsr.di.unimi.it/LSR/Item?id=960
This is how far I've come:
ColorSpan-Showcase.ly
<http://lilypond.1069038.n5.nabble.com/file/n173954/ColorSpan-Showcase.ly>
ColorSpan-Showcase.pdf
<http://lilypond.1069038.n5.nabble.com/file/n173954/ColorSpan-Showcase.pdf>
ColorSpan-Example.ly
<http://lilypond.1069038.n5.nabble.com/file/n173954/ColorSpan-Example.ly>
ColorSpan-Example.pdf
<http://lilypond.1069038.n5.nabble.com/file/n173954/ColorSpan-Example.pdf>


Really impressive!
 
--David


reply via email to

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