Hi Harm,

On Sat, Oct 8, 2011 at 6:38 PM, harm6 <thomasmorle...@googlemail.com> wrote:

>
> 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.
>
>
> All the additional beams should be parallel to the originals.
>
> How to do?
>
>
Hi Harm,

I'm not sure what the best way is to determine a beam's slope, but you might
incorporate the 'position property in your function to determine whether the
slope is positive or negative:

#(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)))
   (beam-positions (ly:grob-property grob 'positions))
   (beam-slant (if (> (car beam-positions) (cdr beam-positions)) -1 1))
           (orig-slope (* beam-slant (/ (- 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))
      ))

Hope this helps!

David
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to