lilypond-user
[Top][All Lists]
Advanced

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

visualize-padding (was: \offset Y-offset)


From: Paolo Prete
Subject: visualize-padding (was: \offset Y-offset)
Date: Wed, 22 Jan 2020 16:26:06 +0100

To Aaron (and any other helpful contributor):

As you can see in the below snippet, the visualize-padding function you so kindly provided, doesn't work in some cases with TupletBracket. Here is a snippet where the bug occurs.

The problem is associated with:

https://lists.gnu.org/archive/html/lilypond-user/2020-01/msg00467.html

Sorry if I insist again with this: is there a fix (or work-around) for it?
The function is ***very*** useful, You can really see what happens with the discussed property, and you can really use therefore a ruler for fine tuning .

Thanks for you help and your patience!


%%%%%%%%%%%%%%%%%

#(define color-good '(0.2 0.5 0.8))
#(define color-bad '(0.8 0.2 0.3))
#(define line-thickness 0.2)
#(define whiteout-thickness 1.5)

visualize-padding = #(define-music-function
  (grob-path color) (symbol-list? color?)
  (define (proc grob)
    (let* ((orig (ly:grob-property grob 'stencil))
           (xex (ly:stencil-extent orig X))
  (yex (ly:stencil-extent orig Y))
           ;(yex (ly:make-unpure-pure-container ly:grob::stencil-height (lambda (grob start end) (ly:grob::stencil-height grob))))
           (dir (ly:grob-property grob 'direction))
           (y (ly:grob-property grob 'padding)))  
 
      (ly:grob-set-property! grob 'layer 1000)
      (ly:grob-set-property! grob 'stencil
        (grob-interpret-markup grob #{
          \markup \overlay {
            \stencil #orig
            \with-dimensions-from \null
            \translate #(cons (interval-index xex 0)
                              (interval-index yex (- dir)))
            \overlay {
              \with-color #color
              \override #'(style . outline)
              \override #`(thickness . ,whiteout-thickness)
              \whiteout
              \scale #(cons 1 (- dir))
              \path #0.2 #`(
                (moveto 0 -2) (lineto 0 0)
                (moveto -0.5 -1) (lineto 0 0) (lineto 0.5 -1)
                (moveto -1 0) (lineto 1 0))

              \with-color #color
              \override #'(style . outline)
              \override #`(thickness . ,whiteout-thickness)
              \whiteout
              \scale #(cons 1 dir)
              \translate #(cons 0 (- y))
              \path #line-thickness #`(
                (moveto 0 -2) (lineto 0 0)
                (moveto -0.5 -1) (lineto 0 0) (lineto 0.5 -1)
                (moveto -1 0) (lineto 1 0))
            }
          } #}))))

  #{ \override $grob-path .after-line-breaking = #proc #})

%%%%%%%%%%%%%
   
upper = {
 {
   \visualize-padding TupletBracket #color-good
   \times 3/3 {
   c'''4*2/3-\fermata \change Staff = "lower"
   c'''4*2/3 g'''4*2/3 }
   c'''
 
   
   }  

} %end upper                                                                                                                                                                                                                                                                            
lower = { s4 s s}

\score {
  \new PianoStaff <<
    \new Staff = "upper" \upper
    \new Staff = "lower" \lower
  >>
  \layout { }
  \midi { }
}

%%%%%%%%%%%%%

reply via email to

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