lilypond-user
[Top][All Lists]
Advanced

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

Re: ly:stencil-extent gives not the exact value?


From: Thomas Morley
Subject: Re: ly:stencil-extent gives not the exact value?
Date: Sun, 23 Oct 2011 14:47:26 +0200

Hi David,

2011/10/23 David Nalesnik <address@hidden>
Hi Harm,

I'm guessing that it's an issue with the markup command \beam.  Looking at the definition in define-markup-commands.scm, it seems that 'blot-diameter isn't taken into account in the calculation of width and thickness.   (Is this intentional or a defect?)  

Surely you noticed that I'm not a native-english-speaker. This is one of the cases where I've got a problem. I can't translate blot-diameter and so I don't know what it is or how to use. (Of course I know how to translate "blot" and "diameter", but I'm in the dark with the meaning of "blot-diameter" of a polygon. There are some other files in .scm where it is used, but these doesn't enlights me too)
 
The following fixes the problem with the beam's length and thickness, and will work when you change the staff size:

\version "2.14.2"

#(set-global-staff-size 24)

#(define (test-stencil grob)
 (let* ((beam (ly:beam::print grob))
        (b-d (ly:output-def-lookup (ly:grob-layout grob) 'blot-diameter))
        (beam-extent-x (ly:stencil-extent beam X))
        (beam-length-x (interval-length beam-extent-x))
        (single-beam-thickness (ly:grob-property grob 'beam-thickness))
        (beam-positions (ly:grob-property grob 'positions))
        (mrkp (markup #:beam (- beam-length-x b-d)
                             0               ;; level Beams only!
                             (- single-beam-thickness b-d)))
        (new-Beam (ly:stencil-in-color
                    (ly:stencil-translate-axis
                      (ly:stencil-translate-axis
                        (grob-interpret-markup grob mrkp)
                        -0.024 X)               ;; why??
                      (car beam-positions)
                      Y)
                    1 0 0)))
    new-Beam))

\relative c' {
 \override Beam #'layer = #-4
 \once \override Beam #'stencil = #test-stencil
 e'8 [e]
 \once \override Beam #'color = #red
 e [e]
 \override Beam #'color = #green
 f8 [f]
}

So I don't understand it totaly, but I can copy and paste. :)
Your suggestion works fine!

Thanks a lot!
  Harm


reply via email to

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