Re: visualize-padding
On Sat, Jan 25, 2020 at 3:05 PM Aaron Hill wrote: > On 2020-01-24 9:12 am, Paolo Prete wrote: > > I'm trying to implement the work-around you suggested. > > TupletNumber doesn't cause the discussed weird space. > > > nstead, simply replace the normal stencil procedure > (ly:tuplet-bracket::print) with a custom one, overlaying whatever you > need. In 2.19, there is grob-transformer, which makes this easy: > > That's great, thanks! At this point I ask you: could I use the same procedure for all the visualize-* functions, or is there a particular reason for which you made the override inside after-line-breaking? I just checked that the same example you provided works for direction = #DOWN too, which you did not take into account in the function itself (but you used it in the after-line-breaking procedure). Best, Paolo
Re: visualize-padding
On 2020-01-24 9:12 am, Paolo Prete wrote: I'm trying to implement the work-around you suggested. TupletNumber doesn't cause the discussed weird space. However, this weird space happens as soon as I access the stencil (or any property of it) of the TupletBracket grob Then, even if I get the bracket's grob with (ly:grob-object number-grob 'bracket), I can't access its stencil, nor its y-extent through this variable. Is this what you were suggesting or do I have to follow another method? Alas, my workaround required that you did not need to touch TupletBracket's stencil property at all. Rather, switching to TupletNumber might have provided you a grob that would host the visualization more reliably. But if you need to access TupletBracket's stencil from after-line-breaking, there is no getting around the issue. In digging more deeply, the unexpected added space looks to come from accessing the TupletBracket's positions property; and since stencil depends on positions internally, querying the stencil triggers the behavior. This property is concerned with the vertical placement of the ends of the bracket, and its computation involves checking a number of associated grobs (e.g. NoteColumns and Beams). By querying positions too early in the layout process, this seems to unintentionally lock in bad values resulting in improper spacing. And unfortunately, TupletBracket's after-line-breaking procedure gets invoked *before* its positions property would normally be queried, so my visualization hack interferes with the usual timing of things. Since TupletBracket's stencil appears to be consulted fairly late in the game, you probably do not need to bother with after-line-breaking at all. Instead, simply replace the normal stencil procedure (ly:tuplet-bracket::print) with a custom one, overlaying whatever you need. In 2.19, there is grob-transformer, which makes this easy: \version "2.19.83" \paper { #(set-paper-size "a9landscape") top-margin = 0.75\cm line-width = 3.5\cm indent = 0 ragged-right = ##f tagline = ##f } visualize-stencil-extent-and-origin = #(define-music-function (grob-path) (symbol-list?) (define proc (grob-transformer 'stencil (lambda (grob orig) (let* ((xex (ly:stencil-extent orig X)) (yex (ly:stencil-extent orig Y))) (ly:grob-set-property! grob 'layer 1000) (grob-interpret-markup grob #{ \markup \with-dimensions-from \stencil #orig \overlay { \with-color #'(0.2 0.7 0.9) \override #'(style . outline) \override #`(thickness . 1.2) \whiteout \path #0.1 #`( (moveto ,(- (car xex) 1.5) ,(car yex)) (lineto ,(+ (cdr xex) 1.5) ,(car yex)) (moveto ,(- (car xex) 1.5) ,(cdr yex)) (lineto ,(+ (cdr xex) 1.5) ,(cdr yex)) (moveto ,(car xex) ,(- (car yex) 1.5)) (lineto ,(car xex) ,(+ (cdr yex) 1.5)) (moveto ,(cdr xex) ,(- (car yex) 1.5)) (lineto ,(cdr xex) ,(+ (cdr yex) 1.5))) \with-color #'(0.9 0.4 0.2) \override #'(style . outline) \override #`(thickness . 0.9) \whiteout \path #0.1 #`( (moveto -1.5 -1.5) (lineto 1.5 1.5) (moveto -1.5 1.5) (lineto 1.5 -1.5)) \override #'(style . outline) \override #`(thickness . 0.6) \whiteout \stencil #orig } #} ) #{ \override $grob-path .stencil = #proc #}) \fixed c' { \visualize-stencil-extent-and-origin TupletBracket \tuplet 3/2 { c2 f8 bes } } -- Aaron Hill
Re: visualize-padding
On Wed, Jan 22, 2020 at 11:56 PM Aaron Hill wrote: > On 2020-01-22 7:26 am, Paolo Prete wrote: > > 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 . > > But be aware > that you might have to do things the other way around, working from > TupletNumber.after-line-breaking which would mean getting the bracket > from the number: (ly:grob-object number-grob 'bracket). > > Hi Aaron, I'm trying to implement the work-around you suggested. TupletNumber doesn't cause the discussed weird space. However, this weird space happens as soon as I access the stencil (or any property of it) of the TupletBracket grob Then, even if I get the bracket's grob with (ly:grob-object number-grob 'bracket), I can't access its stencil, nor its y-extent through this variable. Is this what you were suggesting or do I have to follow another method? Thanks! Best, Paolo
Re: visualize-padding
Y > > All of my helper functions for overlaying stencils are really just > hacks; they might work for some grobs and fail for others. And when > things stop working, you just have to look for another hack. For > instance, if messing with the stencil for TupletBracket is not working, > perhaps you could use another grob to host the debug annotation. > TupletNumber might be more accepting of modification, which you should > be able to get via (ly:grob-object bracket-grob 'number). But be aware > that you might have to do things the other way around, working from > TupletNumber.after-line-breaking which would mean getting the bracket > from the number: (ly:grob-object number-grob 'bracket). > > > Your work is great. Finally all these properties are *clarified*, and they are very far from the obscure/missing/messed up documentation. We will have to talk again about this in the next days. (I did not think about the TupletNumber workaround. Thanks) Best, Paolo
Re: visualize-padding
On 2020-01-22 7:26 am, Paolo Prete wrote: 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 . I started to take a look at this, but got side-tracked. My work schedule is erratic at the best of days, plus I have been trying to get over a cold; so I am uncertain I will be able to dig in more deeply. My initial impression is that accessing certain properties out of sequence can cause problems. The NR includes a brief section on unpure-pure-containers mentioning how one must be careful when accessing properties relating to Y-axis concerns. Beam in particular is called out as something to avoid touching, and I imagine that TupletBracket cares about Beam. I also know there is internal caching of computed results at various stages of processing, so perhaps an unintended side-effect of these things is that it all goes awry when the normal pattern of access is interrupted. And since much of this work is done at the C++ level, it becomes difficult for Scheme code to influence effectively. All of my helper functions for overlaying stencils are really just hacks; they might work for some grobs and fail for others. And when things stop working, you just have to look for another hack. For instance, if messing with the stencil for TupletBracket is not working, perhaps you could use another grob to host the debug annotation. TupletNumber might be more accepting of modification, which you should be able to get via (ly:grob-object bracket-grob 'number). But be aware that you might have to do things the other way around, working from TupletNumber.after-line-breaking which would mean getting the bracket from the number: (ly:grob-object number-grob 'bracket). -- Aaron Hill
visualize-padding (was: \offset Y-offset)
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 { } } %