lilypond-user
[Top][All Lists]
Advanced

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

How to read out the slope of a beam?


From: harm6
Subject: How to read out the slope of a beam?
Date: Sat, 8 Oct 2011 16:38:30 -0700 (PDT)

Hi,

trying to hack Beam stencil, I need to read out the slope of the original
Beam. I thought reading out the y-extent, the x-extent and using the
quotient would do the job. But I was wrong: this quotient can't be negativ.

Here's my test-code:

\version "2.14.2"

#(define (test grob)
     (let* ((beam (ly:beam::print grob))
            (dir (ly:beam::calc-direction grob))
            (beam-extent-x (ly:stencil-extent beam X))
            (beam-length-x (interval-length beam-extent-x))
            (beam-extent-y (ly:stencil-extent beam Y))
            (beam-length-y (interval-length beam-extent-y))
            (beam-thickness (* 0.48 (ly:output-def-lookup (ly:grob-layout
grob) 'staff-space)))
            (orig-slope (/ (- beam-length-y beam-thickness) beam-length-x))
            
            (markup-a (markup #:with-color red
                              #:beam beam-length-x      
                                            orig-slope          
                                            beam-thickness))
            )   ;; end of defs in let*

   (ly:stencil-add
       beam
     (ly:stencil-translate-axis
       (grob-interpret-markup grob markup-a)
       (* dir 4) Y))
       ))
       
%--------------------- Test
----------------------------------------------------

\relative c' {
        \override Beam #'stencil = #test
        c8[ c]
        c c' 
        c c,
        s4
\break
        c'8 [ c]
        c c'
        c [c,]
        s4
}

All the additional beams should be parallel to the originals.

How to do?

Thanks,
  Harm
-- 
View this message in context: 
http://old.nabble.com/How-to-read-out-the-slope-of-a-beam--tp32617534p32617534.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.




reply via email to

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